Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="utf-8">
<title>Named access on the window object - Removing elements</title>
<link rel="author" title="Matthew Phillips" href="mailto:matthew@matthewphillips.info">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
"use strict";
test(() => {
const img = document.createElement("img");
img.setAttribute("id", "foo");
document.body.appendChild(img);
assert_equals(window.foo, img);
document.body.removeChild(img);
assert_false("foo" in window);
}, "Removing an element must update the named properties");
test(() => {
const text = document.createTextNode("foo");
document.body.appendChild(text);
const img = document.createElement("img");
img.setAttribute("id", "removed");
document.body.appendChild(img);
assert_equals(window.removed, img);
document.body.removeChild(text);
assert_equals(window.removed, img);
}, "Removing a non-element node must not cause errors");
</script>