Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't think the thesis of the article is that it hinders reusability, though — it's that anything built on the DOM presents significant limitations compared to what we can do with JavaScript.

The example of passing dynamic styles to a web component is a good one: since attributes have to be strings, you have to handle serialization somewhere rather than have it Just Work, like it does with most modern JavaScript frameworks.



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.


When 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?


> 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?


The W3C editor's draft for custom elements clearly states that attributes are sequences of DOMString: https://w3c.github.io/webcomponents/spec/custom/#concept-cus...


So? Properties are objects and children are nodes.


So, 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!"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: