Skip to content

Commit 78d2678

Browse files
authored
Allow more characters in custom element names
This follows whatwg/dom#1079.
1 parent 167802e commit 78d2678

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
@@ -3358,6 +3358,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
33583358
<li><dfn data-x-href="https://dom.spec.whatwg.org/#abortcontroller-signal-abort">signal abort</dfn></li>
33593359
<li><dfn data-x="AbortSignal-add" data-x-href="https://dom.spec.whatwg.org/#abortsignal-add">add</dfn></li>
33603360
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name">get an attribute by name</dfn> algorithm</li>
3361+
<li><dfn data-x-href="https://dom.spec.whatwg.org/#valid-element-local-name">valid element local name</dfn></li>
33613362
</ul>
33623363

33633364
<p>The following features are defined in <cite>UI Events</cite>: <ref>UIEVENTS</ref></p>
@@ -73369,43 +73370,52 @@ document.body.append(parent);
7336973370

7337073371
<hr>
7337173372

73372-
<p>A <dfn export>valid custom element name</dfn> is a sequence of characters <var>name</var> that
73373-
meets all of the following requirements:</p>
73373+
<p>A string <var>name</var> is a <dfn export>valid custom element name</dfn> if all of the
73374+
following are true:</p>
7337473375

7337573376
<ul>
7337673377
<li>
73377-
<p><var>name</var> must match the <code
73378-
data-x="prod-PotentialCustomElementName">PotentialCustomElementName</code> production:</p>
73378+
<p><var>name</var> is a <span>valid element local name</span>;</p>
7337973379

73380-
<dl>
73381-
<dt><code data-x=""><dfn
73382-
data-x="prod-PotentialCustomElementName">PotentialCustomElementName</dfn> ::=</code></dt>
73383-
<dd><code data-x="">[a-z] (<span data-x="prod-PCENChar">PCENChar</span>)* '-'
73384-
(<span data-x="prod-PCENChar">PCENChar</span>)*</code></dd>
73385-
73386-
<dt><code data-x=""><dfn data-x="prod-PCENChar">PCENChar</dfn> ::=</code></dt>
73387-
<dd><code data-x="">"-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] |
73388-
[#xF8-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] |
73389-
[#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
73390-
[#x10000-#xEFFFF]</code></dd>
73391-
</dl>
73380+
<p class="note">This ensures the custom element can be created with <code
73381+
data-x="dom-Document-createElement">createElement()</code>.</p>
73382+
</li>
7339273383

73393-
<p>This uses the <a href="https://www.w3.org/TR/xml/#sec-notation">EBNF notation</a> from the
73394-
<cite>XML</cite> specification. <ref>XML</ref></p>
73384+
<li>
73385+
<p><var>name</var>'s 0th <span>code point</span> is an <span>ASCII lower alpha</span>;</p>
73386+
73387+
<p class="note">This ensures the HTML parser will treat the name as a tag name instead of as
73388+
text.</p>
7339573389
</li>
7339673390

7339773391
<li>
73398-
<p><var>name</var> must not be any of the following:</p>
73392+
<p><var>name</var> does not contain any <span data-x="ASCII upper alpha">ASCII upper
73393+
alphas</span>;</p>
73394+
73395+
<p class="note">This ensures the user agent can always treat HTML elements
73396+
ASCII-case-insensitively.</p>
73397+
</li>
73398+
73399+
<li>
73400+
<p><var>name</var> contains a U+002D (-); and</p>
73401+
73402+
<p class="note">This is used for namespacing and to ensure forward compatibility (since no
73403+
elements will be added to HTML, SVG, or MathML with hyphen-containing local names going
73404+
forward).</p>
73405+
</li>
73406+
73407+
<li>
73408+
<p><var>name</var> is not one of the following:</p>
7339973409

7340073410
<ul class="brief">
73401-
<li><code data-x="">annotation-xml</code></li>
73402-
<li><code data-x="">color-profile</code></li>
73403-
<li><code data-x="">font-face</code></li>
73404-
<li><code data-x="">font-face-src</code></li>
73405-
<li><code data-x="">font-face-uri</code></li>
73406-
<li><code data-x="">font-face-format</code></li>
73407-
<li><code data-x="">font-face-name</code></li>
73408-
<li><code data-x="">missing-glyph</code></li>
73411+
<li>"<code data-x="">annotation-xml</code>"</li>
73412+
<li>"<code data-x="">color-profile</code>"</li>
73413+
<li>"<code data-x="">font-face</code>"</li>
73414+
<li>"<code data-x="">font-face-src</code>"</li>
73415+
<li>"<code data-x="">font-face-uri</code>"</li>
73416+
<li>"<code data-x="">font-face-format</code>"</li>
73417+
<li>"<code data-x="">font-face-name</code>"</li>
73418+
<li>"<code data-x="">missing-glyph</code>"</li>
7340973419
</ul>
7341073420

7341173421
<p class="note">The list of names above is the summary of all hyphen-containing element names
@@ -73414,34 +73424,14 @@ document.body.append(parent);
7341473424
</li>
7341573425
</ul>
7341673426

73417-
<div class="note">
73418-
<p>These requirements ensure a number of goals for <span data-x="valid custom element name">valid
73419-
custom element names</span>:</p>
73420-
73421-
<ul>
73422-
<li><p>They start with an <span>ASCII lower alpha</span>, ensuring that the HTML parser will
73423-
treat them as tags instead of as text.</li>
73424-
73425-
<li><p>They do not contain any <span data-x="ASCII upper alpha">ASCII upper alphas</span>,
73426-
ensuring that the user agent can always treat HTML elements ASCII-case-insensitively.</p></li>
73427-
73428-
<li><p>They contain a hyphen, used for namespacing and to ensure forward compatibility (since no
73429-
elements will be added to HTML, SVG, or MathML with hyphen-containing local names in the
73430-
future).</p></li>
73431-
73432-
<li><p>They can always be created with <code
73433-
data-x="dom-Document-createElement">createElement()</code> and <code
73434-
data-x="dom-Document-createElementNS">createElementNS()</code>, which have restrictions that go
73435-
beyond the parser's.</p></li>
73436-
</ul>
73437-
73438-
<p>Apart from these restrictions, a large variety of names is allowed, to give maximum
73439-
flexibility for use cases like <code data-x="">&lt;math-α></code> or <code
73440-
data-x="">&lt;emotion-😍></code>.</p>
73441-
</div>
73427+
<p>Apart from these restrictions, a large variety of names is allowed, to give maximum
73428+
flexibility for use cases like <code data-x="">&lt;math-α></code> or <code
73429+
data-x="">&lt;emotion-😍></code>.</p>
7344273430

7344373431
<div w-nodev>
7344473432

73433+
<hr>
73434+
7344573435
<p>A <dfn export>custom element definition</dfn> describes a <span>custom element</span> and
7344673436
consists of:</p>
7344773437

0 commit comments

Comments
 (0)