LibWeb: SVG use element shadow roots should be closed, not open

This goes against the spec but matches all other browser engines.
This commit is contained in:
Andreas Kling 2025-08-07 16:32:28 +02:00 committed by Alexander Kalenik
commit 42802b0785
Notes: github-actions[bot] 2025-08-07 20:17:24 +00:00
3 changed files with 16 additions and 2 deletions

View file

@ -36,8 +36,10 @@ void SVGUseElement::initialize(JS::Realm& realm)
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGUseElement); WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGUseElement);
Base::initialize(realm); Base::initialize(realm);
// The shadow tree is open (inspectable by script), but read-only. // NOTE: The spec says "The shadow tree is open (inspectable by script), but read-only."
auto shadow_root = realm.create<DOM::ShadowRoot>(document(), *this, Bindings::ShadowRootMode::Open); // This doesn't actually match other browsers, and there's a spec issue to change it.
// Spec bug: https://github.com/w3c/svgwg/issues/875
auto shadow_root = realm.create<DOM::ShadowRoot>(document(), *this, Bindings::ShadowRootMode::Closed);
// The user agent must create a use-element shadow tree whose host is the use element itself // The user agent must create a use-element shadow tree whose host is the use element itself
set_shadow_root(shadow_root); set_shadow_root(shadow_root);

View file

@ -0,0 +1,2 @@
null
[object ShadowRoot]

View file

@ -0,0 +1,10 @@
<!doctype html>
<script src="../include.js"></script>
<svg id="foo"></svg>
<svg><use id="use" href="#foo" /></svg>
<script>
test(() => {
println(use.shadowRoot);
println(internals.getShadowRoot(use));
});
</script>