It looks like the quote came from this article titled: What the Heck is Shadow DOM?
The shadow DOM is part of the DOM (but a virtual DOM is a hidden copy of the DOM. Sorry about the earlier confusion with virtual DOM!). From reviewing this W3 Spec again, it appears that the shadow DOM is simply a reusable DOM fragment. The browser will see it & will render it's contents.
This specification describes a method of combining multiple DOM trees into one hierarchy and how these trees interact with each other within a document, thus enabling better composition of the DOM.
This technology has been around since at least 2006, when I started using .innerHTML & templates inside of JavaScript, to build reusable DOM fragments. It's not new technology. It's simply being documented in 2015 by the W3C as an official specification.
What is interesting are these CSS attributes & pseudo-selectors, which operate on the Shadow DOM, but aren't part of the Real DOM. They are described at the bottom of the Composed Trees section of the W3 Spec.
::shadow pseudo element
/deep/ combinator, which was replaced with a >>>
combinator (or shadow piercing descendant combinator)
::content pseudo-element
:host pseudo-class and :host() functional pseudo-class
:host-context() functional pseudo-class
They kind of add to these selectors, which people sometimes use to create <div>
tags with carets/pointers to other on-screen elements:
::before
& ::after
Additional Update:
I found more details at Shadow DOM 101 link. When viewing the "Hello my name is Bob... Shellie" example (about 1/2 way down the page), which is right above this text block...
Now we have achieved separation of content and presentation. The content is in the document; the presentation is in the Shadow DOM. They are automatically kept in sync by the browser when it comes time to render something.
... we can inspect the DOM & see what the shadow DOM looks like. It looks like this, where both CSS & HTML can be encapsulated inside of a "shadow DOM" element, which is hidden inside of a <div>
tag. See: https://developer.chrome.com/devtools/docs/settings-files/show-shadow-dom.png
It seems like the idea is to encapsulate the CSS & HTML, so that it doesn't spill out onto other areas of the page. Nor allow other existing / on-page code, to affect what is inside of that encapsulated code block. Older examples of this encapsulation would be hidden <iframe>
tag, which were designed to show ads but stop 3rd party ad code from breaking the JS on our really cool web pages.
Here are some more Shadow DOM links:
- Shadow DOM 101
- Shadow DOM 201
- Shadow DOM 301
- Visualizing Shadow DOM Concepts