https://github.com/webcomponents/template-shadowroot
https://github.com/webcomponents/template-shadowroot
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/webcomponents/template-shadowroot
- Owner: webcomponents
- License: bsd-3-clause
- Created: 2019-11-06T17:02:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-09T17:34:28.000Z (almost 2 years ago)
- Last Synced: 2024-10-29T15:32:28.508Z (over 1 year ago)
- Language: TypeScript
- Size: 1.89 MB
- Stars: 38
- Watchers: 12
- Forks: 8
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Declarative Shadow DOM Ponyfill
Declarative Shadow DOM for SSR
A [ponyfill](https://ponyfill.com/) of the API described by Mason Freed at https://github.com/mfreed7/declarative-shadow-dom.
## Overview
This package provides a function, `hydrateShadowRoots`, that converts `` elements with a `shadowrootmode` attribute into ShadowRoots on the template's parent element.
This allows HTML with shadow roots to be serialized to plain HTML, and the serialized shadow roots "rehydrated" (separate from component hydration) on the client.
`` elements are transformed bottom up so that in the case where they're nested, all elements within the declarative shadow tree stay inert until they have all been moved from their `` elements.
If native support for `` is present, `hydrateShadowRoots` does nothing when called.
### Known limitations
* Does not currently look into imperatively created shadow roots.
* The mutation observer implementation
* May not work properly in the face of streaming HTML parsing. Needs investigation.
* Will not notice imperatively created `` elements inside of other shadow roots.
* Not enough benchmarks, and benchmarks of insufficient quality to be confident of good performance.