3 ms·
Isn't this React??? Shadow DOM, in particular, provides a lightweight encapsulation for DOM trees by allowing a creation of a parallel tree on an element calle
by meesles 11y ago
Isn't this React???
Shadow DOM, in particular, provides a lightweight encapsulation for DOM trees by allowing a creation of a parallel tree on an element called a “shadow tree” that replaces the rendering of the element without modifying the underlying DOM tree.
- deleted 11y ago[deleted]
- gravity13 11y agoReact does not use Shadow Dom. And React is not related to CSS first-hand, though people are trying apply the same modularization principles of DOM encapsulation to the CSSOM. Not only that - there's a lot of implication that come with Shadow Dom that will make it impossible to just plug and play with React. Namely, the fact that is stops the cascading effect of Cascading Style Sheets. Whereever you are stylizing large swathes of your app with common css code, you'll need to rethink by either treating css as a module and importing at the new shadow root, or by rewriting your css to be more redundant. These tradeoffs require considerable buy-in, which leads me to suspect React will continue to be agnostic towards shadow dom.
- deleted 11y ago[deleted]
- chc 11y agoIt's similar in some ways, but not exactly the same. This allows an element on a page to contain a whole tree of elements while still appearing as a single element from the outside (i.e. for the purposes of DOM methods, CSS, etc.).
- morgante 11y agoNo, the virtual DOM and the Shadow DOM are distinct concepts. The virtual DOM is a parallel representation of the DOM which is used to diff against—it's only used for "logic" rather than display. The Shadow DOM is actually almost the opposite: it replaces the visual/interactive presentation of the tree without changing the exposure of the underlying elements to the rest of the page. That being said, they bother offer mechanisms for writing modularized frontend code effectively.