diff --git a/resources/declarative-shadow-dom-polyfill.js b/resources/declarative-shadow-dom-polyfill.js index 99a3e911eb63362..73643398a912820 100644 --- a/resources/declarative-shadow-dom-polyfill.js +++ b/resources/declarative-shadow-dom-polyfill.js @@ -17,7 +17,8 @@ function polyfill_declarative_shadow_dom(root) { root.querySelectorAll("template[shadowrootmode]").forEach(template => { const mode = template.getAttribute("shadowrootmode"); const delegatesFocus = template.hasAttribute("shadowrootdelegatesfocus"); - const shadowRoot = template.parentNode.attachShadow({ mode, delegatesFocus }); + const clonable = template.hasAttribute("shadowrootclonable"); + const shadowRoot = template.parentNode.attachShadow({ mode, delegatesFocus, clonable }); shadowRoot.appendChild(template.content); template.remove(); polyfill_declarative_shadow_dom(shadowRoot); diff --git a/shadow-dom/declarative/declarative-shadow-dom-basic.html b/shadow-dom/declarative/declarative-shadow-dom-basic.html index 8799978804a53b4..8bc6bec5f50f741 100644 --- a/shadow-dom/declarative/declarative-shadow-dom-basic.html +++ b/shadow-dom/declarative/declarative-shadow-dom-basic.html @@ -141,6 +141,28 @@ assert_true(!!host.shadowRoot,"No shadow root found"); assert_false(host.shadowRoot.delegatesFocus,"delegatesFocus should be false without the shadowrootdelegatesfocus attribute"); }, 'Declarative Shadow DOM: delegates focus attribute'); + +test(() => { + const div = document.createElement('div'); + div.setHTMLUnsafe(` +
+ +
+ `); + var host = div.querySelector('#host'); + assert_true(!!host.shadowRoot,"No shadow root found"); + assert_true(host.shadowRoot.clonable,"clonable should be true"); + div.setHTMLUnsafe(` +
+ +
+ `); + host = div.querySelector('#host'); + assert_true(!!host.shadowRoot,"No shadow root found"); + assert_false(host.shadowRoot.clonable,"clonable should be false without the shadowrootclonable attribute"); +}, 'Declarative Shadow DOM: clonable attribute');