Skip to content

Commit e4e0ea8

Browse files
authored
Editorial: use IDL to simplify create an element
Per whatwg/html#4525 a custom element constructor is required to be an HTMLElement. Also, rather than assume another specification will make foreign namespace objects implement HTMLElement, let's instead assert that does not happen as we cannot test it.
1 parent 98564fc commit e4e0ea8

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

dom.bs

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6041,20 +6041,14 @@ given a <var>document</var>, <var>localName</var>, <var>namespace</var>, and opt
60416041
<li><p>Set <var>result</var> to the result of <a>constructing</a> <var>C</var>, with no
60426042
arguments.
60436043

6044+
<li><p>Assert: <var>result</var>'s <a for=Element>custom element state</a> and
6045+
<a for=Element>custom element definition</a> are initialized.
6046+
60446047
<li>
6045-
<p>If <var>result</var> does not implement the {{HTMLElement}} interface, then <a>throw</a> a
6046-
<code>TypeError</code>.
6047-
6048-
<div class=note>
6049-
<p>This is meant to be a brand check to ensure that the object was allocated by the HTML
6050-
element constructor. See <a href="https://github.com/heycam/webidl/issues/97">webidl #97</a>
6051-
about making this more precise.
6052-
6053-
<p>If this check passes, then <var>result</var> will already have its
6054-
<a for=Element>custom element state</a> and <a for=Element>custom element definition</a>
6055-
initialized.
6056-
</div>
6057-
</li>
6048+
<p>Assert: <var>result</var>'s <a for=Element>namespace</a> is the <a>HTML namespace</a>.
6049+
6050+
<p class=note>IDL enforces that <var>result</var> is an {{HTMLElement}} object, which all use
6051+
the <a>HTML namespace</a>.
60586052

60596053
<li><p>If <var>result</var>'s <a for=Element>attribute list</a> <a for=list>is not empty</a>,
60606054
then <a>throw</a> a "{{NotSupportedError!!exception}}" {{DOMException}}.
@@ -6068,17 +6062,6 @@ given a <var>document</var>, <var>localName</var>, <var>namespace</var>, and opt
60686062
<li><p>If <var>result</var>'s <a for=Node>node document</a> is not <var>document</var>, then
60696063
<a>throw</a> a "{{NotSupportedError!!exception}}" {{DOMException}}.
60706064

6071-
<li>
6072-
<p>If <var>result</var>'s <a for=Element>namespace</a> is not the <a>HTML namespace</a>,
6073-
then <a>throw</a> a "{{NotSupportedError!!exception}}" {{DOMException}}.
6074-
6075-
<p class="note">As of the time of this writing, every element that implements the
6076-
{{HTMLElement}} interface is also in the <a>HTML namespace</a>, so this check is currently
6077-
redundant with the above brand check. However, this is not guaranteed to be true forever in
6078-
the face of potential specification changes, such as converging certain SVG and HTML
6079-
interfaces.
6080-
</li>
6081-
60826065
<li><p>If <var>result</var>'s <a for=Element>local name</a> is not equal to
60836066
<var>localName</var>, then <a>throw</a> a "{{NotSupportedError!!exception}}" {{DOMException}}.
60846067

0 commit comments

Comments
 (0)