News for hackers. Stuff that matters.
Re:HTML Attributes vs. DOM Properties by sir_pepe on Thursday April 25, 2024 @01:41AM (#40153843)
When you want to pass an object to a web component without going through JSON or some other stringification procedure.
Re:HTML Attributes vs. DOM Properties by politelemon on Thursday April 25, 2024 @03:00AM (#40154352)
How do you read it in the web component afterwards? Passing it via property sounds quite useful.
Re:HTML Attributes vs. DOM Properties by throwitaway1123 on Thursday April 25, 2024 @04:33AM (#40154950)
Web components are implemented using custom elements which are just plain JS classes that extend the HTMLElement class, so you would access the property the same way you would access a property in a normal JS class.
Re:HTML Attributes vs. DOM Properties by jaffathecake on Thursday April 25, 2024 @04:57AM (#40155100)
The author of the thread is arguing against properties.
Re:HTML Attributes vs. DOM Properties by throwitaway1123 on Thursday April 25, 2024 @05:26AM (#40155281)
Yes, I know. I wasn't making a prescriptive comment about whether or not developers should use properties, I was just making a descriptive comment about how properties are accessed in a web component to answer the specific question politelemon asked.
Re:HTML Attributes vs. DOM Properties by politelemon on Thursday April 25, 2024 @01:20PM (#40160389)
Thanks understood, that makes it quite simple and intuitive thinking about it.
Re:HTML Attributes vs. DOM Properties by jaffathecake on Thursday April 25, 2024 @03:38AM (#40154606)
Event listeners? Image data?
Re:HTML Attributes vs. DOM Properties by runarberg on Thursday April 25, 2024 @12:26PM (#40159541)
element.srcObject is very useful for <video> elements when the srcObject is a direct stream feed from the camera. I don’t even know how I would go about passing that as a string attribute.

https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaEl...