template-contentmethod-innerHTML-ambiguous.html (1334B)
1 <!DOCTYPE HTML> 2 <meta charset="utf-8" /> 3 <title>HTML partial updates: patching via innerHTML with ambiguous target</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 <div id="container"></div> 8 <div id="placeholder" contentname="placeholder">Old content in light DOM</div> 9 <script> 10 // The contentname "placeholder" appears both after the container on which innerHTML is 11 // set, and in created fragment. Which element should be updated depends on the 12 // details of how this is spec'd. 13 test(() => { 14 const container = document.getElementById("container"); 15 const outerPlaceholder = document.getElementById("placeholder"); 16 container.innerHTML = `<div id="placeholder" contentname="placeholder">Old content in innerHTML</div><template contentmethod="replace-children"><div contentname="placeholder">New content</div></template>`; 17 const innerPlaceholder = container.firstChild; 18 assert_equals(innerPlaceholder.id, "placeholder"); 19 // patches apply inside the fragment 20 assert_equals(outerPlaceholder.textContent, "Old content in light DOM"); 21 assert_equals(innerPlaceholder.textContent, "New content"); 22 }, "<template patchfor> in innerHTML patching inner element"); 23 </script>