diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 0848ba215ad..bb5408dba60 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -288,7 +288,7 @@ WebIDL::ExceptionOr> Document::create_and_initialize( // URL: creationURL // current document readiness: "loading" // about base URL: navigationParams's about base URL - // FIXME: allow declarative shadow roots: true + // allow declarative shadow roots: true auto document = HTML::HTMLDocument::create(window->realm()); document->m_type = type; document->m_content_type = move(content_type); @@ -300,6 +300,7 @@ WebIDL::ExceptionOr> Document::create_and_initialize( document->set_url(*creation_url); document->m_readiness = HTML::DocumentReadyState::Loading; document->m_about_base_url = navigation_params.about_base_url; + document->set_allow_declarative_shadow_roots(true); document->m_window = window; @@ -5209,4 +5210,16 @@ Vector> Document::find_matching_text(String const& query, return matches; } +// https://dom.spec.whatwg.org/#document-allow-declarative-shadow-roots +bool Document::allow_declarative_shadow_roots() const +{ + return m_allow_declarative_shadow_roots; +} + +// https://dom.spec.whatwg.org/#document-allow-declarative-shadow-roots +void Document::set_allow_declarative_shadow_roots(bool allow) +{ + m_allow_declarative_shadow_roots = allow; +} + } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index a81bd639e72..67b3b8f0345 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -400,6 +400,9 @@ public: bool is_fully_active() const; bool is_active() const; + [[nodiscard]] bool allow_declarative_shadow_roots() const; + void set_allow_declarative_shadow_roots(bool); + JS::NonnullGCPtr history(); JS::NonnullGCPtr history() const; @@ -929,6 +932,9 @@ private: // instead they generate boxes as if they were siblings of the root element. OrderedHashTable> m_top_layer_elements; OrderedHashTable> m_top_layer_pending_removals; + + // https://dom.spec.whatwg.org/#document-allow-declarative-shadow-roots + bool m_allow_declarative_shadow_roots { false }; }; template<> diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index adf52dc9199..722f6890bd2 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -246,6 +246,9 @@ WebIDL::ExceptionOr BrowsingContext // about base URL: creatorBaseURL document->set_about_base_url(creator_base_url); + // allow declarative shadow roots: true + document->set_allow_declarative_shadow_roots(true); + // 16. If creator is non-null, then: if (creator) { // 1. Set document's referrer to the serialization of creator's URL.