removing.html (1102B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Named access on the window object - Removing elements</title> 4 <link rel="author" title="Matthew Phillips" href="mailto:matthew@matthewphillips.info"> 5 <link rel="help" href="https://html.spec.whatwg.org/#named-access-on-the-window-object"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 9 <body> 10 <script> 11 "use strict"; 12 13 test(() => { 14 const img = document.createElement("img"); 15 img.setAttribute("id", "foo"); 16 document.body.appendChild(img); 17 assert_equals(window.foo, img); 18 19 document.body.removeChild(img); 20 assert_false("foo" in window); 21 }, "Removing an element must update the named properties"); 22 23 test(() => { 24 const text = document.createTextNode("foo"); 25 document.body.appendChild(text); 26 27 const img = document.createElement("img"); 28 img.setAttribute("id", "removed"); 29 document.body.appendChild(img); 30 assert_equals(window.removed, img); 31 32 document.body.removeChild(text); 33 assert_equals(window.removed, img); 34 }, "Removing a non-element node must not cause errors"); 35 </script>