1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +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:
Andreas Kling 2021-02-10 18:22:20 +01:00
parent d597626ea1
commit 2eddd74e85
2 changed files with 10 additions and 0 deletions

View file

@ -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());
}
}