1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

LibWeb: Make Node::root return a reference

The root of a node can never be null, as "the root of an object is
itself, if its parent is null, or else it is the root of its parent."

https://dom.spec.whatwg.org/#concept-tree-root
This commit is contained in:
Luke Wilde 2021-09-02 19:27:42 +01:00 committed by Andreas Kling
parent 7f46022e66
commit f7f37eaa0f
5 changed files with 24 additions and 20 deletions

View file

@ -35,15 +35,15 @@ static EventTarget* retarget(EventTarget* left, EventTarget* right)
return left;
auto* left_node = verify_cast<Node>(left);
auto* left_root = left_node->root();
auto& left_root = left_node->root();
if (!is<ShadowRoot>(left_root))
return left;
if (is<Node>(right) && left_root->is_shadow_including_inclusive_ancestor_of(verify_cast<Node>(*right)))
if (is<Node>(right) && left_root.is_shadow_including_inclusive_ancestor_of(verify_cast<Node>(*right)))
return left;
auto* left_shadow_root = verify_cast<ShadowRoot>(left_root);
left = left_shadow_root->host();
auto& left_shadow_root = verify_cast<ShadowRoot>(left_root);
left = left_shadow_root.host();
}
}