3 ms·
It's also the main problem React faces when trying to incorporate/integrate with Web Components. React Components can be arbitrarily complex and accept arbitrar
by dmitriid 10y ago
It's also the main problem React faces when trying to incorporate/integrate with Web Components. React Components can be arbitrarily complex and accept arbitrarily complex properties.
Web Components work ok as "leaf" nodes: then it's just a component with string props/attributes.
The inverse is nigh impossible: Web Components can only deal with strings, so you would end up with yet another incompatible wrapper à la Polymer if you want to do anything remotely complex.
- Touche 10y agoWhen you say "Web Components", what is it that you are talking about? I assume you mean custom elements. Custom elements are DOM Nodes like any other. They are represented in JavaScript like any other object. Of course you can pass non-strings to DOM elements. Open your development console and type document.createElement('div').user = {name: 'Dmitri'}. Did you get an error?
- spankalee 10y ago> React Components can be arbitrarily complex and accept arbitrarily complex properties. Web Components can be arbitrarily complex and accept arbitrarily complex properties or children. Did you even try Web Components before spewing falsehoods?
- jakelazaroff 10y agoThe W3C editor's draft for custom elements clearly states that attributes are sequences of DOMString: https://w3c.github.io/webcomponents/spec/custom/#concept-custom-element-definition-observed-attributes https://w3c.github.io/webcomponents/spec/custom/#concept-cus...
- spankalee 10y agoSo? Properties are objects and children are nodes.
- dmitriid 10y agoSo, basically, "we push everything to JS and we have the curse of the empty body tag where everything is rendered with JS" turned into "we push everything to JS and we have the curse of the empty body tag where everything is rendered with JS ... but with WebComponents! So it's cool now!"