Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/dom/documents/dom-tree-accessors/nameditem-img-name-removed.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset=utf-8>
<title>Named items: img exposed by id stops being exposed when its name is removed</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<img id="foo" name="x">
<object id="foo"></object>
<object id="foo"></object>
<script>
test(function() {
let img = document.querySelector("img#foo");
assert_equals(document.foo.length, 3, "before removal");
assert_in_array(img, [...document.foo], "before removal contains img");
img.removeAttribute("name");
assert_equals(document.foo.length, 2, "after removal");
assert_false([...document.foo].includes(img), "after removal does not contain img");
}, "An img exposed by its id (id + name) is no longer exposed by id after its name attribute is removed.");
</script>