blob: dfb0a1e053c0546d393f8e910404332b03c7f03f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/*
* Polyfill for attaching shadow trees for declarative Shadow DOM for implementations that do not support
* declarative Shadow DOM.
*
* root: The root of the subtree to perform the attachments in
*/
function polyfill_declarative_shadow_dom(root) {
root.querySelectorAll("template[shadowroot]").forEach(template => {
const mode = template.getAttribute("shadowroot");
const shadowRoot = template.parentNode.attachShadow({ mode });
shadowRoot.appendChild(template.content);
template.remove();
polyfill_declarative_shadow_dom(shadowRoot);
});
}
|