This behaviour is all downside and no upside.
The spec should have simply defined a dom object and a javascript object to be one and the same, with attributes and properties being the same thing.
This behaviour is all downside and no upside.
The spec should have simply defined a dom object and a javascript object to be one and the same, with attributes and properties being the same thing.
Acting this flippant isn’t helpful.
Could it be that this whole paradigm (which by the way has been devised for a different and much simpler use case, and abused forever since) isn't sustainable anymore?
If anything, it’s odd that they added these conveniences like reflection that make it more magical than it should be.
(Edited for clarity)
Since JavaScript was invented specifically to manipulate the DOM, I'm not sure that that follows.
https://ecma-international.org/wp-content/uploads/ECMA-262_1...
The reason for NodeList instead of Array is the same
For example the Event interface definition[0] contains parts like
const unsigned short NONE = 0;
[0] https://dom.spec.whatwg.org/#interface-eventIn modern DOM APIs, it would be a string enum.
I would not surprise me if modern addition or revisions to the spec were more JS inspired
I agree that any sort of convention/rule here that’d be 100% fixed would’ve been better, but it wouldn’t be simple.
Sure, they maybe can't be serialized, but that isn't an issue.
[0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
<div onClick="func()">...</div>
Now, I'm not a JS developer, so my opinion shouldn't count for much, but that looks like a much less usable standard to me.
// our document is like:
// <foo bar="asdf">
let foo = document.querySelector('foo');
console.log('bar', foo.bar); // cool, prints asdf
foo.bar = 'nice'; // <foo> element is now <foo bar="nice">
foo.addEventListener('some-event', e => console.log(e)); // wait, what?
So DOM element methods would instead be free functions like: HTMLElement.addEventListener(foo, 'some-event', e => console.log(e));
It's a matter of taste, but I for one appreciate having object method calls in JavaScript.Maybe I’ve just been writing backend code for too long. I see an interface like this and I figure there’s some weird shit going on under the hood, and some kind developer from the past gave me the best and safest wrapper she could.
A cynic might point out it added a lot of makework to the lives of its creators. And that this is why we can't have nice things like proper specs instead of 'living' ones.