diff options
Diffstat (limited to '')
-rw-r--r-- | testing/web-platform/tests/resources/declarative-shadow-dom-polyfill.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/testing/web-platform/tests/resources/declarative-shadow-dom-polyfill.js b/testing/web-platform/tests/resources/declarative-shadow-dom-polyfill.js new file mode 100644 index 0000000000..dfb0a1e053 --- /dev/null +++ b/testing/web-platform/tests/resources/declarative-shadow-dom-polyfill.js @@ -0,0 +1,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); + }); +} |