© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
J. KrauseDeveloping Web Components with TypeScripthttps://doi.org/10.1007/978-1-4842-6840-7_3

3. Shadow DOM

Jörg Krause1  
(1)
Berlin, Berlin, Germany
 

The Shadow DOM brings encapsulation. It allows a component to have its very own DOM tree, which can’t be accidentally accessed from the main document, may have local style rules, and more. When creating a new component, the component’s developer doesn’t need to know anything about the application this particular component is running in. That further simplifies the development.

In older literature, you may find the elements <shadow> and <content>. Both are deprecated and no longer part of the current Web Component ...

Get Developing Web Components with TypeScript: Native Web Development Using Thin Libraries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.