mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +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:
parent
7f46022e66
commit
f7f37eaa0f
5 changed files with 24 additions and 20 deletions
|
@ -16,11 +16,12 @@ ShadowRoot::ShadowRoot(Document& document, Element& host)
|
|||
set_host(host);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6
|
||||
EventTarget* ShadowRoot::get_parent(const Event& event)
|
||||
{
|
||||
if (!event.composed()) {
|
||||
auto& events_first_invocation_target = verify_cast<Node>(*event.path().first().invocation_target);
|
||||
if (events_first_invocation_target.root() == this)
|
||||
if (&events_first_invocation_target.root() == this)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue