News for hackers. Stuff that matters.
Re:HTML Attributes vs. DOM Properties by londons_explore on Thursday April 25, 2024 @05:40AM (#40155369)
think the other way round... allow DOM attribute values to be of any javascript type...

Sure, they maybe can't be serialized, but that isn't an issue.

Re:HTML Attributes vs. DOM Properties by afavour on Thursday April 25, 2024 @08:11AM (#40156505)
In what way is that not an issue? What happens when you use .outerHTML to get a string representation of the element? Not to mention that, unavoidably, the entire page HTML arrives to the browser as a string.
Re:HTML Attributes vs. DOM Properties by londons_explore on Thursday April 25, 2024 @09:07AM (#40157053)
Same is true of real javascript objects vs JSON. For example, you can't put Date() in JSON. Nor objects with a prototype.
Re:HTML Attributes vs. DOM Properties by no_wizard on Thursday April 25, 2024 @10:36AM (#40158113)
I do want to point out for those who don't know, on objects with a prototype (such as a class) you can control how JSON.stringify works by adding a special method `toJSON`[0] which will control how that object is serialized.

[0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:HTML Attributes vs. DOM Properties by afavour on Thursday April 25, 2024 @09:36AM (#40157397)
Right… and that’s an issue people have to work around every day. Non string values in HTML world similarly be an issue everyone would have to work around.
Re:HTML Attributes vs. DOM Properties by strix_varius on Thursday April 25, 2024 @07:01AM (#40155922)
That doesn't make any sense. DOM attributes are serialized as a fundamental part of their expression.
Re:HTML Attributes vs. DOM Properties by layer8 on Thursday April 25, 2024 @10:59AM (#40158391)
So is JavaScript. Granted, it would be more straightforward if it were a Lisp.