Post

HTML forms are so broken. With every other element, you can do this: <div id="foo"> div⁠.⁠id // "foo" Forms work the same way too: <form id="bar"> form⁠.⁠id // "bar" But then: <form id="bar"> <input name="id"> form⁠.⁠id // the input element 🤡

And it doesn't stop with attributes. An input named "click" breaks form⁠.⁠click(), etc.

At least that gives you an explicit error. The problem is silent errors like `something ${element.id}`

And the document.activeElement case is even worse because it will be an element, but not the actual activeElement.

0 reposts2 likes

I tried this just now in Chrome: <form> <input name="activeElement"> </form> <script> const form = document.querySelector('form') console.log(form.activeElement) // input console.log(document.activeElement) // body </script> How did you get activeElement to propagate?

Thanks, that was the missing piece of the puzzle ❤️ The DOM API still has a lot of darkness. I assume historical. I quoted with correct info this time.