LibWeb/DOM: Copy "allow declarative shadow roots" to template document

This flag defaults to false for new Documents, such as the one created
here for use by template elements' contents. Without setting it to
true, nothing inside a template can have a declarative shadow dom.

As noted, this appears to be a spec issue. I am not convinced that this
is the correct fix, but it is simple and does solve the issue without
any apparent regressions.
This commit is contained in:
Sam Atkins 2025-11-25 16:06:44 +00:00 committed by Jelle Raaijmakers
parent 8ca4833885
commit aac387bcc6
Notes: github-actions[bot] 2025-11-26 08:53:57 +00:00
3 changed files with 12 additions and 9 deletions

View file

@ -4511,6 +4511,11 @@ GC::Ref<DOM::Document> Document::appropriate_template_contents_owner_document()
if (document_type() == Type::HTML)
new_document->set_document_type(Type::HTML);
// AD-HOC: Copy over the "allow declarative shadow roots" flag, otherwise no elements inside templates will
// be able to have declarative shadow roots.
// Spec issue: https://github.com/whatwg/html/issues/11955
new_document->set_allow_declarative_shadow_roots(allow_declarative_shadow_roots());
// 3. Set doc's associated inert template document to new doc.
m_associated_inert_template_document = new_document;
}