Skip to content

Commit

Permalink
Don't include namespace in IsValidShadowHostName check
Browse files Browse the repository at this point in the history
In [1] I mistakenly changed the check for whether an element has a
valid shadow name to include the full qualified name rather than just
the local name. Using only the local name is correct per the intent
of the spec [2] (although the key word is missing from the spec due to
a bug; see [3]).

Fix this check (and the corresponding check for EditContext) to only
include the local name.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/4617146
[2] https://dom.spec.whatwg.org/#concept-attach-a-shadow-root
[3] whatwg/dom#1273

Bug: 331239166
Change-Id: Ic01b26ac592ce16c36017925db702f5b495b6165
  • Loading branch information
dandclark authored and chromium-wpt-export-bot committed Apr 3, 2024
1 parent fa48865 commit 58b822a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions shadow-dom/host-with-namespace.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" lang="en" >
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="default-namespace"></div>
<xhtml:div id="explicit-namespace"></xhtml:div>

<script>
<![CDATA[
test(function() {
const defaultNamespaceHost = document.getElementById('default-namespace');
defaultNamespaceHost.attachShadow({mode: 'open'});
assert_not_equals(defaultNamespaceHost.shadowRoot, null, "attachShadow should work on node with default namespace");
}, 'attachShadow with a default-namespaced element');

test(function() {
const explicitNamespaceHost = document.getElementById('explicit-namespace');
explicitNamespaceHost.attachShadow({mode: 'open'});
assert_not_equals(explicitNamespaceHost.shadowRoot, null, "attachShadow should work on node with explicit namespace");
}, 'Test attachShadow with a namespaced element');
]]>
</script>
</body>
</html>

0 comments on commit 58b822a

Please sign in to comment.