Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /dom/ranges/Range-intersectsNode-shadow.html - WPT Dashboard Interop Dashboard
<!doctype html>
<title>Range.intersectsNode with Shadow DOM</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="host"></div>
<script>
test(() => {
const host = document.getElementById("host");
host.attachShadow({ mode: "open" }).innerHTML = `<span>ABC</span>`;
const range = document.createRange();
range.selectNode(document.body);
assert_true(range.intersectsNode(host), "Should intersect host");
assert_false(range.intersectsNode(host.shadowRoot), "Should not intersect shadow root");
assert_false(range.intersectsNode(host.shadowRoot.firstElementChild), "Should not intersect shadow span");
}, "Range.intersectsNode() doesn't return true for shadow children in other trees");
</script>