Skip to content

Commit aca19e2

Browse files
committed
Clarify create an element assertion
Instead of saying "initialized" let's enumerate what these values can actually be and provide an example of something that is potentially unexpected. Fixes #1338.
1 parent f8b241f commit aca19e2

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

dom.bs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6954,8 +6954,30 @@ null, or a {{CustomElementRegistry}} object <var>registry</var> (default "<code>
69546954
<li><p>Set <var>result</var> to the result of <a>constructing</a> <var>C</var>, with no
69556955
arguments.
69566956

6957-
<li><p>Assert: <var>result</var>'s <a for=Element>custom element state</a> and
6958-
<a for=Element>custom element definition</a> are initialized.
6957+
<li>
6958+
<p><a for=/>Assert</a>: <var>result</var>'s <a for=Element>custom element state</a> is
6959+
"<code>custom</code>" and its <a for=Element>custom element definition</a> is non-null,
6960+
<var>result</var>'s <a for=Element>custom element state</a> is "<code>precustomized</code>",
6961+
or <var>result</var>'s <a for=Element>custom element state</a> is neither
6962+
"<code>custom</code>" nor "<code>precustomized</code>" and its
6963+
<a for=Element>custom element definition</a> is null.
6964+
6965+
<div class=example id=example-return-override>
6966+
<pre><code class=lang-javascript>
6967+
customElements.define("x-example", class extends HTMLElement {
6968+
constructor() {
6969+
// Non-conformant: returns an existing element instead of calling super().
6970+
return document.createElement("p");
6971+
}
6972+
});
6973+
6974+
document.createElement("x-example");
6975+
</code></pre>
6976+
6977+
<p>Here <var>result</var> is the <code>p</code> <a for=/>element</a>, whose
6978+
<a for=Element>custom element state</a> is "<code>uncustomized</code>" and whose
6979+
<a for=Element>custom element definition</a> is null.
6980+
</div>
69596981

69606982
<li>
69616983
<p>Assert: <var>result</var>'s <a for=Element>namespace</a> is the <a>HTML namespace</a>.

0 commit comments

Comments
 (0)