fix(parser): Set shadow’s available to element internals in attach_declarative_shadow (#36173)

Aligns the implementation with step 8.5 of the HTML spec for parsing
a <template> element in the InHead state by setting
shadow_root.set_available_to_element_internals(true) after
assigning the shadow root to the template’s contents.

Also removes tests/wpt/meta/shadow-dom/declarative/declarative-shadow-dom-available-to-element-internals.html.ini
since the test expectations are now updated accordingly.

Spec reference: https://html.spec.whatwg.org/multipage/#parsing-main-inhead

Signed-off-by: Emmanuel Elom <elomemmanuel007@gmail.com>
This commit is contained in:
elomscansio 2025-03-27 18:20:42 +01:00 committed by GitHub
parent b4ac6e8ce2
commit a8063b8b4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -1477,6 +1477,9 @@ impl TreeSink for Sink {
let shadow = shadow_root.upcast::<DocumentFragment>();
template_element.set_contents(Some(shadow));
// Step 8.5. Set shadows available to element internals to true.
shadow_root.set_available_to_element_internals(true);
Ok(())
},
Err(_) => Err(String::from("Attaching shadow fails")),

View file

@ -1,3 +0,0 @@
[declarative-shadow-dom-available-to-element-internals.html]
[Declarative Shadow DOM: shadow root should be available to element internals]
expected: FAIL