3 ms·
When you want to pass an object to a web component without going through JSON or some other stringification procedure.
by sir_pepe 2y ago
When you want to pass an object to a web component without going through JSON or some other stringification procedure.
- politelemon 2y agoHow do you read it in the web component afterwards? Passing it via property sounds quite useful.
- throwitaway1123 2y agoWeb 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.
- jaffathecake 2y agoThe author of the thread is arguing against properties.
- throwitaway1123 2y agoYes, 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.
- politelemon 2y agoThanks understood, that makes it quite simple and intuitive thinking about it.
- jaffathecake 2y agoEvent listeners? Image data?
- runarberg 2y agoelement.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/HTMLMediaElement/srcObject https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaEl...