UNPKG

968 BMarkdownView Raw
1# Synthetic Shadow Root
2
3## Summary
4
5This is a polyfill for ShadowRoot that was tailor-made for LWC in order to meet the performance goals of the Lightning Platform. This doesn't mean that it cannot be used with any other framework, but we took shortcuts and made compromises that might not align well with other frameworks.
6
7## Compromises
8
9- Default content for `<slot>` elements is always empty.
10- `slotchange` is only available directly on the slot (it doesn't bubble as in the case of the native implementation)
11- Dispatching events directly on the `ShadowRoot` instance isn't allowed because the events will always leak into the host, and we have no way to contain them.
12- If you use `MutationObserver` to watch changes in a DOM tree, disconnect it or you will cause a memory leak. Note that a component can observe mutations only in its own template. It can't observe mutations within the shadow tree of other custom elements.
13
14## Missing features
15
16TBD