mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibWeb: Add DOM::Node::parent_or_shadow_host()
This is useful when you want to traverse across shadow boundaries.
This commit is contained in:
parent
d597626ea1
commit
2eddd74e85
2 changed files with 10 additions and 0 deletions
|
@ -259,4 +259,11 @@ void Node::inserted_into(Node&)
|
|||
set_needs_style_update(true);
|
||||
}
|
||||
|
||||
ParentNode* Node::parent_or_shadow_host()
|
||||
{
|
||||
if (is<ShadowRoot>(*this))
|
||||
return downcast<ShadowRoot>(*this).host();
|
||||
return downcast<ParentNode>(parent());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,6 +57,9 @@ public:
|
|||
using TreeNode<Node>::ref;
|
||||
using TreeNode<Node>::unref;
|
||||
|
||||
ParentNode* parent_or_shadow_host();
|
||||
const ParentNode* parent_or_shadow_host() const { return const_cast<Node*>(this)->parent_or_shadow_host(); }
|
||||
|
||||
// ^EventTarget
|
||||
virtual void ref_event_target() final { ref(); }
|
||||
virtual void unref_event_target() final { unref(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue