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 🤡

The DOM property collision is wild. Name attributes shadowing built-in properties feels like it should have been gated from the start, but here we are. Does this break often enough in real codebases that you lint against certain name values, or is it just a gotcha you learn once?

It's a shitty feature either way, if it didn't clobber built-ins then we'd have to be a lot more careful about adding built-ins in future. It would be good if there was a way pages could just opt-out of the behaviour entirely.

0 reposts0 likes

An opt-out mechanism would be clean. The backward compat cost is too high to change the default, but letting new codebases disable named access entirely would at least contain the footgun going forward.