Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /dom/nodes/ParentNode-querySelectorAll-removed-elements.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>querySelectorAll must not return removed elements</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="container"></div>
<script>
"use strict";
setup({ single_test: true });
const container = document.querySelector("#container");
function getIDs() {
return [...container.querySelectorAll("a.test")].map(el => el.id);
}
container.innerHTML = `<a id="link-a" class="test">a link</a>`;
assert_array_equals(getIDs(), ["link-a"], "Sanity check: initial setup");
container.innerHTML = `<a id="link-b" class="test"><img src="foo.jpg"></a>`;
assert_array_equals(getIDs(), ["link-b"], "After replacement");
container.innerHTML = `<a id="link-a" class="test">a link</a>`;
assert_array_equals(getIDs(), ["link-a"], "After changing back to the original HTML");
done();
</script>