mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +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:
parent
fd297a3248
commit
18a4455d43
3 changed files with 35 additions and 2 deletions
|
@ -1259,8 +1259,7 @@ bool Node::is_shadow_including_descendant_of(Node const& other) const
|
|||
|
||||
// and A’s root’s host is a shadow-including inclusive descendant of B.
|
||||
auto& shadow_root = verify_cast<ShadowRoot>(root());
|
||||
// NOTE: While host is nullable because of inheriting from DocumentFragment, shadow roots always have a host.
|
||||
return shadow_root.host()->is_shadow_including_inclusive_descendant_of(other);
|
||||
return shadow_root.host() && shadow_root.host()->is_shadow_including_inclusive_descendant_of(other);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue