Skip to content

Commit 60a89f0

Browse files
committed
Allow more characters in custom element names
This follows whatwg/dom#1079.
1 parent 94a9b1d commit 60a89f0

File tree

1 file changed

+42
-52
lines changed

1 file changed

+42
-52
lines changed

source

Lines changed: 42 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3155,6 +3155,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
31553155
<dfn data-x="concept-element-is-value" data-x-href="https://dom.spec.whatwg.org/#concept-element-is-value"><code data-x="">is</code> value</dfn></li>
31563156

31573157
<li><dfn data-x-href="https://dom.spec.whatwg.org/#mutationobserver"><code>MutationObserver</code></dfn> interface and <dfn data-x-href="https://dom.spec.whatwg.org/#mutation-observers">mutation observers</dfn> in general</li>
3158+
<li><dfn data-x-href="https://dom.spec.whatwg.org/#valid-element-local-name">valid element local name</dfn></li>
31583159
</ul>
31593160

31603161
<p>The following features are defined in <cite>UI Events</cite>: <ref spec=UIEVENTS></p>
@@ -69985,43 +69986,52 @@ document.body.append(parent);
6998569986

6998669987
<hr>
6998769988

69988-
<p>A <dfn export>valid custom element name</dfn> is a sequence of characters <var>name</var> that
69989-
meets all of the following requirements:</p>
69989+
<p>A string <var>name</var> is a <dfn export>valid custom element name</dfn> if all of the
69990+
following conditions are true:</p>
6999069991

6999169992
<ul>
6999269993
<li>
69993-
<p><var>name</var> must match the <code
69994-
data-x="prod-PotentialCustomElementName">PotentialCustomElementName</code> production:</p>
69994+
<p><var>name</var> is a <span>valid element local name</span>;</p>
6999569995

69996-
<dl>
69997-
<dt><code data-x=""><dfn
69998-
data-x="prod-PotentialCustomElementName">PotentialCustomElementName</dfn> ::=</code></dt>
69999-
<dd><code data-x="">[a-z] (<span data-x="prod-PCENChar">PCENChar</span>)* '-'
70000-
(<span data-x="prod-PCENChar">PCENChar</span>)*</code></dd>
70001-
70002-
<dt><code data-x=""><dfn data-x="prod-PCENChar">PCENChar</dfn> ::=</code></dt>
70003-
<dd><code data-x="">"-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] |
70004-
[#xF8-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] |
70005-
[#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
70006-
[#x10000-#xEFFFF]</code></dd>
70007-
</dl>
69996+
<p class="note">This ensures the custom element can be created with <code
69997+
data-x="dom-Document-createElement">createElement()</code>.</p>
69998+
</li>
69999+
70000+
<li>
70001+
<p><var>name</var>'s first <span>code point</span> is an <span>ASCII lower alpha</span>;</p>
70002+
70003+
<p class="note">This ensures the HTML parser will treat the name as a tag name instead of as
70004+
text.</p>
70005+
</li>
7000870006

70009-
<p>This uses the <a href="https://www.w3.org/TR/xml/#sec-notation">EBNF notation</a> from the
70010-
<cite>XML</cite> specification. <ref spec=XML></p>
70007+
<li>
70008+
<p><var>name</var> does not contain any <span data-x="ASCII upper alpha">ASCII upper
70009+
alphas</span>;</p>
70010+
70011+
<p class="note">This ensures the user agent can always treat HTML elements
70012+
ASCII-case-insensitively.</p>
7001170013
</li>
7001270014

7001370015
<li>
70014-
<p><var>name</var> must not be any of the following:</p>
70016+
<p><var>name</var> contains a U+002D (-); and</p>
70017+
70018+
<p class="note">This used for namespacing and to ensure forward compatibility (since no
70019+
elements will be added to HTML, SVG, or MathML with hyphen-containing local names in the
70020+
future).</p>
70021+
</li>
70022+
70023+
<li>
70024+
<p><var>name</var> is not one of the following:</p>
7001570025

7001670026
<ul class="brief">
70017-
<li><code data-x="">annotation-xml</code></li>
70018-
<li><code data-x="">color-profile</code></li>
70019-
<li><code data-x="">font-face</code></li>
70020-
<li><code data-x="">font-face-src</code></li>
70021-
<li><code data-x="">font-face-uri</code></li>
70022-
<li><code data-x="">font-face-format</code></li>
70023-
<li><code data-x="">font-face-name</code></li>
70024-
<li><code data-x="">missing-glyph</code></li>
70027+
<li>"<code data-x="">annotation-xml</code>"</li>
70028+
<li>"<code data-x="">color-profile</code>"</li>
70029+
<li>"<code data-x="">font-face</code>"</li>
70030+
<li>"<code data-x="">font-face-src</code>"</li>
70031+
<li>"<code data-x="">font-face-uri</code>"</li>
70032+
<li>"<code data-x="">font-face-format</code>"</li>
70033+
<li>"<code data-x="">font-face-name</code>"</li>
70034+
<li>"<code data-x="">missing-glyph</code>"</li>
7002570035
</ul>
7002670036

7002770037
<p class="note">The list of names above is the summary of all hyphen-containing element names
@@ -70030,34 +70040,14 @@ document.body.append(parent);
7003070040
</li>
7003170041
</ul>
7003270042

70033-
<div class="note">
70034-
<p>These requirements ensure a number of goals for <span data-x="valid custom element name">valid
70035-
custom element names</span>:</p>
70036-
70037-
<ul>
70038-
<li><p>They start with an <span>ASCII lower alpha</span>, ensuring that the HTML parser will
70039-
treat them as tags instead of as text.</li>
70040-
70041-
<li><p>They do not contain any <span data-x="ASCII upper alpha">ASCII upper alphas</span>,
70042-
ensuring that the user agent can always treat HTML elements ASCII-case-insensitively.</p></li>
70043-
70044-
<li><p>They contain a hyphen, used for namespacing and to ensure forward compatibility (since no
70045-
elements will be added to HTML, SVG, or MathML with hyphen-containing local names in the
70046-
future).</p></li>
70047-
70048-
<li><p>They can always be created with <code
70049-
data-x="dom-Document-createElement">createElement()</code> and <code
70050-
data-x="dom-Document-createElementNS">createElementNS()</code>, which have restrictions that go
70051-
beyond the parser's.</p></li>
70052-
</ul>
70053-
70054-
<p>Apart from these restrictions, a large variety of names is allowed, to give maximum
70055-
flexibility for use cases like <code data-x="">&lt;math-α></code> or <code
70056-
data-x="">&lt;emotion-😍></code>.</p>
70057-
</div>
70043+
<p>Apart from these restrictions, a large variety of names is allowed, to give maximum
70044+
flexibility for use cases like <code data-x="">&lt;math-α></code> or <code
70045+
data-x="">&lt;emotion-😍></code>.</p>
7005870046

7005970047
<div w-nodev>
7006070048

70049+
<hr>
70050+
7006170051
<p>A <dfn>custom element definition</dfn> describes a <span>custom element</span> and consists
7006270052
of:</p>
7006370053

0 commit comments

Comments
 (0)