summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/DOM
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2020-11-21 18:49:09 +0000
committerAndreas Kling <kling@serenityos.org>2020-11-22 18:20:56 +0100
commitc5e15d9282369c3747b8c61b9839988e0ae281da (patch)
tree4c429a358de54184da0efaf7995f330af8891dad /Libraries/LibWeb/DOM
parente8b3a6558191e97ffab28943865a9459f013969e (diff)
downloadserenity-c5e15d9282369c3747b8c61b9839988e0ae281da.zip
LibWeb: Expose ParentNode.{first,last}ElementChild
I needed these to write the event dispatcher test.
Diffstat (limited to 'Libraries/LibWeb/DOM')
-rw-r--r--Libraries/LibWeb/DOM/Document.idl6
-rw-r--r--Libraries/LibWeb/DOM/DocumentFragment.idl4
-rw-r--r--Libraries/LibWeb/DOM/Element.idl3
-rw-r--r--Libraries/LibWeb/DOM/ParentNode.cpp10
-rw-r--r--Libraries/LibWeb/DOM/ParentNode.h3
5 files changed, 25 insertions, 1 deletions
diff --git a/Libraries/LibWeb/DOM/Document.idl b/Libraries/LibWeb/DOM/Document.idl
index 0c4f46d1cc..a6610cd8d1 100644
--- a/Libraries/LibWeb/DOM/Document.idl
+++ b/Libraries/LibWeb/DOM/Document.idl
@@ -8,8 +8,12 @@ interface Document : Node {
readonly attribute DOMString contentType;
Element? getElementById(DOMString id);
- Element? querySelector(DOMString selectors);
ArrayFromVector getElementsByTagName(DOMString tagName);
+
+ readonly attribute Element? firstElementChild;
+ readonly attribute Element? lastElementChild;
+
+ Element? querySelector(DOMString selectors);
ArrayFromVector querySelectorAll(DOMString selectors);
Element createElement(DOMString tagName);
diff --git a/Libraries/LibWeb/DOM/DocumentFragment.idl b/Libraries/LibWeb/DOM/DocumentFragment.idl
index 0b42cb9bfe..46e7d36dba 100644
--- a/Libraries/LibWeb/DOM/DocumentFragment.idl
+++ b/Libraries/LibWeb/DOM/DocumentFragment.idl
@@ -1,6 +1,10 @@
interface DocumentFragment : Node {
Element? getElementById(DOMString id);
+
+ readonly attribute Element? firstElementChild;
+ readonly attribute Element? lastElementChild;
+
Element? querySelector(DOMString selectors);
ArrayFromVector querySelectorAll(DOMString selectors);
diff --git a/Libraries/LibWeb/DOM/Element.idl b/Libraries/LibWeb/DOM/Element.idl
index d4499e5268..a68a86bc05 100644
--- a/Libraries/LibWeb/DOM/Element.idl
+++ b/Libraries/LibWeb/DOM/Element.idl
@@ -5,6 +5,9 @@ interface Element : Node {
DOMString? getAttribute(DOMString qualifiedName);
void setAttribute(DOMString qualifiedName, DOMString value);
+ readonly attribute Element? firstElementChild;
+ readonly attribute Element? lastElementChild;
+
Element? querySelector(DOMString selectors);
ArrayFromVector querySelectorAll(DOMString selectors);
diff --git a/Libraries/LibWeb/DOM/ParentNode.cpp b/Libraries/LibWeb/DOM/ParentNode.cpp
index 4d668883db..42f435c19e 100644
--- a/Libraries/LibWeb/DOM/ParentNode.cpp
+++ b/Libraries/LibWeb/DOM/ParentNode.cpp
@@ -70,4 +70,14 @@ NonnullRefPtrVector<Element> ParentNode::query_selector_all(const StringView& se
return elements;
}
+RefPtr<Element> ParentNode::first_element_child()
+{
+ return first_child_of_type<Element>();
+}
+
+RefPtr<Element> ParentNode::last_element_child()
+{
+ return last_child_of_type<Element>();
+}
+
}
diff --git a/Libraries/LibWeb/DOM/ParentNode.h b/Libraries/LibWeb/DOM/ParentNode.h
index 7783197f9d..cf8aa6ec86 100644
--- a/Libraries/LibWeb/DOM/ParentNode.h
+++ b/Libraries/LibWeb/DOM/ParentNode.h
@@ -38,6 +38,9 @@ public:
template<typename F>
void for_each_child(F);
+ RefPtr<Element> first_element_child();
+ RefPtr<Element> last_element_child();
+
RefPtr<Element> query_selector(const StringView&);
NonnullRefPtrVector<Element> query_selector_all(const StringView&);