LibWeb: Add Node.parentNode and Node.parentElement to DOM API :^)

This commit is contained in:
Andreas Kling 2020-06-20 22:26:54 +02:00
commit 94cf1f08ec
Notes: sideshowbarker 2024-07-19 05:30:59 +09:00
3 changed files with 22 additions and 0 deletions

View file

@ -179,4 +179,18 @@ bool Node::is_connected() const
return root() && root()->is_document();
}
Element* Node::parent_element()
{
if (!parent() || !is<Element>(parent()))
return nullptr;
return to<Element>(parent());
}
const Element* Node::parent_element() const
{
if (!parent() || !is<Element>(parent()))
return nullptr;
return to<Element>(parent());
}
}