diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 237efce65c0..b55d3564aac 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -323,6 +323,7 @@ void Document::visit_edges(Cell::Visitor& visitor) visitor.visit(m_links); visitor.visit(m_forms); visitor.visit(m_scripts); + visitor.visit(m_all); for (auto& script : m_scripts_to_execute_when_parsing_has_finished) visitor.visit(script.ptr()); @@ -1041,6 +1042,17 @@ JS::NonnullGCPtr Document::scripts() return *m_scripts; } +// https://html.spec.whatwg.org/multipage/dom.html#dom-document-all +JS::NonnullGCPtr Document::all() +{ + if (!m_all) { + m_all = HTMLCollection::create(*this, [](Element const&) { + return true; + }); + } + return *m_all; +} + Color Document::link_color() const { if (m_link_color.has_value()) diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 6f5b1496a1d..d7ae5324781 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -183,6 +183,7 @@ public: JS::NonnullGCPtr links(); JS::NonnullGCPtr forms(); JS::NonnullGCPtr scripts(); + JS::NonnullGCPtr all(); String const& source() const { return m_source; } void set_source(String const& source) { m_source = source; } @@ -494,6 +495,7 @@ private: JS::GCPtr m_links; JS::GCPtr m_forms; JS::GCPtr m_scripts; + JS::GCPtr m_all; }; } diff --git a/Userland/Libraries/LibWeb/DOM/Document.idl b/Userland/Libraries/LibWeb/DOM/Document.idl index a7d979c220b..f4790688728 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.idl +++ b/Userland/Libraries/LibWeb/DOM/Document.idl @@ -69,6 +69,9 @@ interface Document : Node { readonly attribute HTMLCollection forms; readonly attribute HTMLCollection scripts; + // FIXME: Should return an HTMLAllCollection + readonly attribute HTMLCollection all; + Element createElement(DOMString tagName); Element createElementNS(DOMString? namespace, DOMString qualifiedName); DocumentFragment createDocumentFragment();