getElementById-dynamic-002.html (891B)
1 <!doctype html> 2 <title>Shadow DOM: Modifying an element ID inside a disconnected shadow root does not break getElementById</title> 3 <link rel="help" href="https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid"> 4 <link rel="author" name="Simon Wülker"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <div id="host"></div> 8 <script> 9 test(function() { 10 let host = document.getElementById("host"); 11 host.attachShadow({ mode: "open" }).innerHTML = `<div id="test-id"></div>`; 12 let element = host.shadowRoot.getElementById("test-id"); 13 assert_true(!!element); 14 15 host.remove(); 16 host.shadowRoot.getElementById("test-id").id = "new-id"; 17 18 assert_equals(host.shadowRoot.getElementById("new-id"), element); 19 }, "ShadowRoot.getElementById works on elements whose id was modified after the root was disconnected"); 20 </script>