1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:07:36 +00:00

LibWeb: Do not assume a shadow root has a host

After commit ff48b7333c, we remove shadow
roots from elements that are removed from the DOM. Setting a node's
shadow root to null also sets that shadow root's host to null. Thus, the
comment in Node::is_shadow_including_descendant_of that assumes the host
is always non-null is not true.

The test added here would previously crash when interacting with a node
that is a descendant of a removed shadow root.
This commit is contained in:
Timothy Flynn 2023-12-03 14:34:53 -05:00 committed by Andreas Kling
parent fd297a3248
commit 18a4455d43
3 changed files with 35 additions and 2 deletions

View file

@ -0,0 +1,14 @@
<div id=container>
<details open>
<summary>summary</summary>
<span id=node></span>
</details>
</div>
<script type="text/javascript">
let node = document.getElementById("node");
let container = document.getElementById("container");
container.innerHTML = "<span>Pass!</span>";
node.click();
</script>