template-contentmethod-shadow.html (1087B)
1 <!DOCTYPE HTML> 2 <meta charset="utf-8" /> 3 <title>HTML partial updates: patching inside a declarative shadow tree</title> 4 <link rel=help href="https://github.com/WICG/declarative-partial-updates"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <div id="placeholder">Old content in light DOM</div> 9 <div id="container"> 10 <template shadowrootmode="open"> 11 <section id="placeholder" contentname="p">Old content in shadow DOM</section> 12 <template contentmethod="replace-children"><section contentname="p">New content</template> 13 </template> 14 </div> 15 <script> 16 test(() => { 17 assert_equals(document.querySelector("#placeholder").innerText, "Old content in light DOM"); 18 const {shadowRoot} = document.querySelector("#container"); 19 assert_equals(shadowRoot.querySelector("#placeholder").innerText, "New content"); 20 assert_equals(shadowRoot.querySelector("template[patchfor=placeholder]"), null); 21 }, "<template contentmethod> inside a <template shadowrootmode> should apply directly to its target"); 22 23 </script>