3 ms·
(Speaking as someone who worked on the Polymer team for a year, and has been writing React at a separate job for roughly half that) > The componenty composabil
by nevir 11y ago
(Speaking as someone who worked on the Polymer team for a year, and has been writing React at a separate job for roughly half that)
> The componenty composability of React definitely seems real to me, whereas I don't have such optimism about Web Components.
Web components have pretty much the same levels of composability as React, but have promise for even more. The main reason I say this is that the components specs attempt to formalize a surface area for all web webcomponents libraries to interoperate with each other - though we're not to that point yet.
Many of the Polymer core components are a great example of composed elements (sometimes overzealously so). Shadow DOM and insertion points (<content> or <slot>) do wonders for this. (Yes, Polymer 1.0+ backs off from this a little bit)
React really only composes well with elements written in React. It can talk out to native components (and custom elements), but it's awkward enough that you tend to build wrappers to expose a more React-y interface (value, onChange, etc).
---
> I just want an inline iframe, which I know is like saying I want an "inline inline frame". ;)
Assuming that you want these inline frames on a per component basis, we're talking about a ton of overhead per component:
* A new JS VM context (for the sandboxed global and security mechanisms)
* A new render layer (and the the synchronized painting you mention)
* All the other browser bits that would need to be built up
---
DOM is a problem, but it's not the biggest problem, and performance-wise, there have been tremendous improvements in the last few years (Try running your benchmarks again).
However, imagine a world where all elements are defined with a set of public APIs like web components. No more crazy special cased properties, magic methods, etc. Imagine how much cruft the browser vendors could remove from the DOM. Imagine how much faster things would be.
Imagine all of HTML implemented purely in JS, and the browser only exposes the primitives needed to do that.
- cheapsteak 11y ago>Yes, Polymer 1.0+ backs off from this a little bit) I didn't know about this, any guidance on why?
- nevir 11y agoPolymer 1.0 has support for shadow DOM, but also what they call "Shady DOM": https://www.polymer-project.org/1.0/articles/shadydom.html https://www.polymer-project.org/1.0/articles/shadydom.html TL;DR: Shady DOM provides an API that is similar to shadow DOM, but without all the crazy overhead when polyfilling it. The downside is that it's not quite transparent to someone outside of a Polymer element
- lomnakkus 11y agoA very interesting perspective -- that I happen to agree with. There's also nothing preventing you from using web components from React. > Imagine all of HTML implemented purely in JS, and the browser only exposes the primitives needed to do that. It would be interesting to see if that's even remotely feasible with the current "limitations" of Shadow CSS and/or how Shadow CSS would have to be extended to support this.