LbiWeb: Return an HTMLAllCollection from document.all

This commit is contained in:
Shannon Booth 2024-04-01 08:45:59 +02:00 committed by Andreas Kling
parent 1f59e21829
commit 249ee0a30e
3 changed files with 8 additions and 6 deletions

View file

@ -61,6 +61,7 @@
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/Focus.h>
#include <LibWeb/HTML/HTMLAllCollection.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLAreaElement.h>
#include <LibWeb/HTML/HTMLBaseElement.h>
@ -1442,10 +1443,11 @@ JS::NonnullGCPtr<HTMLCollection> Document::scripts()
}
// https://html.spec.whatwg.org/multipage/dom.html#dom-document-all
JS::NonnullGCPtr<HTMLCollection> Document::all()
JS::NonnullGCPtr<HTML::HTMLAllCollection> Document::all()
{
if (!m_all) {
m_all = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const&) {
// The all attribute must return an HTMLAllCollection rooted at the Document node, whose filter matches all elements.
m_all = HTML::HTMLAllCollection::create(*this, HTML::HTMLAllCollection::Scope::Descendants, [](Element const&) {
return true;
});
}

View file

@ -240,7 +240,7 @@ public:
JS::NonnullGCPtr<HTMLCollection> links();
JS::NonnullGCPtr<HTMLCollection> forms();
JS::NonnullGCPtr<HTMLCollection> scripts();
JS::NonnullGCPtr<HTMLCollection> all();
JS::NonnullGCPtr<HTML::HTMLAllCollection> all();
String const& source() const { return m_source; }
void set_source(String source) { m_source = move(source); }
@ -782,7 +782,7 @@ private:
JS::GCPtr<HTMLCollection> m_links;
JS::GCPtr<HTMLCollection> m_forms;
JS::GCPtr<HTMLCollection> m_scripts;
JS::GCPtr<HTMLCollection> m_all;
JS::GCPtr<HTML::HTMLAllCollection> m_all;
// https://html.spec.whatwg.org/#completely-loaded-time
Optional<AK::UnixDateTime> m_completely_loaded_time;

View file

@ -19,6 +19,7 @@
#import <DOM/Range.idl>
#import <DOM/Text.idl>
#import <DOM/TreeWalker.idl>
#import <HTML/HTMLAllCollection.idl>
#import <HTML/HTMLElement.idl>
#import <HTML/HTMLHeadElement.idl>
#import <HTML/HTMLScriptElement.idl>
@ -75,8 +76,7 @@ interface Document : Node {
[SameObject] readonly attribute HTMLCollection forms;
[SameObject] readonly attribute HTMLCollection scripts;
// FIXME: Should return an HTMLAllCollection
readonly attribute HTMLCollection all;
readonly attribute HTMLAllCollection all;
[CEReactions, NewObject] Element createElement(DOMString tagName, optional (DOMString or ElementCreationOptions) options = {});
[CEReactions, NewObject] Element createElementNS([FlyString] DOMString? namespace, DOMString qualifiedName, optional (DOMString or ElementCreationOptions) options = {});