mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:37:35 +00:00
LibWeb: Add Node.parentNode and Node.parentElement to DOM API :^)
This commit is contained in:
parent
94fdf4fa5a
commit
94cf1f08ec
3 changed files with 22 additions and 0 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -101,6 +101,12 @@ public:
|
|||
const Node* root() const;
|
||||
bool is_connected() const;
|
||||
|
||||
Node* parent_node() { return parent(); }
|
||||
const Node* parent_node() const { return parent(); }
|
||||
|
||||
Element* parent_element();
|
||||
const Element* parent_element() const;
|
||||
|
||||
template<typename T>
|
||||
const T* first_child_of_type() const;
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ interface Node : EventTarget {
|
|||
readonly attribute Node? lastChild;
|
||||
readonly attribute Node? previousSibling;
|
||||
readonly attribute Node? nextSibling;
|
||||
readonly attribute Node? parentNode;
|
||||
readonly attribute Element? parentElement;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue