Description
ShadyDOM is a shim for Shadow DOM V1 that is part of the Web Components polyfills. The README says it is less correct than the full ShadowDOM polyfill, but less intrusive and faster. Its usage is transparent when attachShadow is unavailable, and elements are patched as needed so they report the right DOM information. Only the DOM tree accessors and the mutation API are maintained, and some APIs such as MutationObserver are not shimmed. To force ShadyDOM even when the browser has native Shadow DOM, set ShadyDOM = {force: true} in a script before the polyfill loads. Composition is asynchronous for performance, so the composed DOM is ready one microtask after a mutation, and ShadyDOM.flush can force synchronous updates in tests. ShadowDOM-compatible styling is not included, so the README points to the shadycss shim for that. On very old Chrome and Safari versions, ShadyDOM.patch(node) must be called before setting textContent or innerHTML in some cases. The package is for developers who need Shadow DOM behavior in browsers that lack it.…
Highlights
- Shadow DOM V1 shim for browsers without native support
- Transparent use when attachShadow is unavailable
- Force mode with ShadyDOM = {force: true}
- Asynchronous composition with a flush method for tests
- Part of the Web Components polyfills
Ratings & Reviews
No ratings yet
Be the first to rate @webcomponents/shadydom.
People also visit

shadow-dom-testing-library
An extension of DOM-testing-library to provide hooks into the shadow dom
@webcomponents/shadydom FAQ
What is ShadyDOM?
A shim that provides Shadow DOM V1 behavior in browsers that lack native support, and is part of the Web Components polyfills.
Is it the same as the ShadowDOM polyfill?
No. The README says ShadyDOM is less correct than the ShadowDOM polyfill, but less intrusive and faster.
How do I force it on?
Set ShadyDOM = {force: true} in a script before loading the polyfill, which makes it used even when native Shadow DOM is available.
Does it style shadow roots?
No. The README says ShadowDOM-compatible styling needs the shadycss shim.
Which APIs are missing?
The README says only DOM tree accessors and the mutation API are maintained, and APIs such as MutationObserver are not shimmed.
What are the best @webcomponents/shadydom alternatives?
Popular alternatives to @webcomponents/shadydom include @lwc/synthetic-shadow, @webcomponents/shadycss and @webcomponents/custom-elements. See all @webcomponents/shadydom alternatives











