@@ -67280,7 +67280,13 @@ customElements.define("x-foo", class extends HTMLElement {
67280
67280
67281
67281
</div>
67282
67282
67283
- <h4>The <code>ElementInternals</code> interface</h4>
67283
+ <h4>Element internals</h4>
67284
+
67285
+ <p>Certain capabilities are meant to be available to a custom element author, but not to a custom
67286
+ element consumer. These are provided by the <code
67287
+ data-x="dom-attachInternals">element.attachInternals()</code> method, which returns an instance of
67288
+ <code>ElementInternals</code>. The properties and methods of <code>ElementInternals</code> allow
67289
+ control over internal features which the user agent provides to all elements.</p>
67284
67290
67285
67291
<dl class="domintro">
67286
67292
<dt><var>element</var> . <code subdfn data-x="dom-attachInternals">attachInternals()</code></dt>
@@ -67291,29 +67297,74 @@ customElements.define("x-foo", class extends HTMLElement {
67291
67297
element definition, or if it is called twice on the same element.</p></dd>
67292
67298
</dl>
67293
67299
67300
+ <div w-nodev>
67301
+
67302
+ <p>Each <code>HTMLElement</code> has an <dfn>attached internals</dfn> boolean, initially
67303
+ false.</p>
67304
+
67305
+ <p>The <dfn><code data-x="dom-attachInternals">attachInternals()</code></dfn> method steps
67306
+ are:</p>
67307
+
67308
+ <ol>
67309
+ <!-- We could lift this restriction in the future. -->
67310
+ <li><p>If <span>this</span>'s <span data-x="concept-element-is-value"><code data-x="">is</code>
67311
+ value</span> is not null, then throw a <span>"<code>NotSupportedError</code>"</span>
67312
+ <code>DOMException</code>.</p></li>
67313
+
67314
+ <li><p>Let <var>definition</var> be the result of <span data-x="look up a custom element
67315
+ definition">looking up a custom element definition</span> given this's <span>node
67316
+ document</span>, its namespace, its local name, and null as the <span
67317
+ data-x="concept-element-is-value"><code data-x="">is</code> value</span>.</p></li>
67318
+
67319
+ <li><p>If <var>definition</var> is null, then throw an
67320
+ <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
67321
+
67322
+ <li><p>If <var>definition</var>'s <span
67323
+ data-x="concept-custom-element-definition-disable-internals">disable internals</span> is true,
67324
+ then throw a <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
67325
+
67326
+ <li><p>If <span>this</span>'s <span>attached internals</span> is true, then throw an
67327
+ <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
67328
+
67329
+ <li><p>If <span>this</span>'s <span>custom element state</span> is not "<code
67330
+ data-x="">precustomized</code>" or "<code data-x="">custom</code>", then throw a
67331
+ <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
67332
+
67333
+ <li><p>Set <span>this</span>'s <span>attached internals</span> to true.</p></li>
67334
+
67335
+ <li><p>Return a new <code>ElementInternals</code> instance whose <span
67336
+ data-x="internals-target">target element</span> is <span>this</span>.</p></li>
67337
+ </ol>
67338
+
67339
+ <h5>The <code>ElementInternals</code> interface</h5>
67340
+
67341
+ <p>The IDL for the <code>ElementInternals</code> interface is as follows, with the various operations and attributes
67342
+ defined in the following sections:</p>
67343
+
67294
67344
<pre><code class="idl">[Exposed=Window]
67295
67345
interface <dfn>ElementInternals</dfn> {
67296
- // Form-associated custom elements
67346
+ // <a href="#shadow-root-access">Shadow root access</a>
67347
+ readonly attribute <code>ShadowRoot</code>? <span data-x="dom-ElementInternals-shadowRoot">shadowRoot</span>;
67297
67348
67349
+ // <a href="#form-associated-custom-elements">Form-associated custom elements</a>
67298
67350
undefined <span data-x="dom-ElementInternals-setFormValue">setFormValue</span>((<span>File</span> or <span data-x="idl-USVString">USVString</span> or <span>FormData</span>)? value,
67299
- optional (<span>File</span> or <span data-x="idl-USVString">USVString</span> or <span>FormData</span>)? state);
67351
+ optional (<span>File</span> or <span data-x="idl-USVString">USVString</span> or <span>FormData</span>)? state);
67300
67352
67301
67353
readonly attribute <span>HTMLFormElement</span>? <span data-x="dom-ElementInternals-form">form</span>;
67302
67354
67303
67355
undefined <span data-x="dom-ElementInternals-setValidity">setValidity</span>(optional <span>ValidityStateFlags</span> flags = {},
67304
- optional DOMString message,
67305
- optional <span>HTMLElement</span> anchor);
67356
+ optional DOMString message,
67357
+ optional <span>HTMLElement</span> anchor);
67306
67358
readonly attribute boolean <span data-x="dom-ElementInternals-willValidate">willValidate</span>;
67307
67359
readonly attribute <span>ValidityState</span> <span data-x="dom-ElementInternals-validity">validity</span>;
67308
67360
readonly attribute DOMString <span data-x="dom-ElementInternals-validationMessage">validationMessage</span>;
67309
67361
boolean <span data-x="dom-ElementInternals-checkValidity">checkValidity</span>();
67310
67362
boolean <span data-x="dom-ElementInternals-reportValidity">reportValidity</span>();
67311
67363
67312
67364
readonly attribute <span>NodeList</span> <span data-x="dom-ElementInternals-labels">labels</span>;
67313
-
67314
- readonly attribute <code>ShadowRoot</code>? <span data-x="dom-ElementInternals-shadowRoot">shadowRoot</span>;
67315
67365
};
67316
67366
67367
+ // <a href="#accessibility-semantics">Accessibility semantics</a>
67317
67368
ElementInternals includes <span>ARIAMixin</span>;
67318
67369
67319
67370
dictionary <dfn>ValidityStateFlags</dfn> {
@@ -67329,6 +67380,43 @@ dictionary <dfn>ValidityStateFlags</dfn> {
67329
67380
boolean customError = false;
67330
67381
};</code></pre>
67331
67382
67383
+ <p>Each <code>ElementInternals</code> has a <dfn data-x="internals-target">target element</dfn>,
67384
+ which is a <span>custom element</span>.</p>
67385
+
67386
+ </div>
67387
+
67388
+ <h5>Shadow root access</h5>
67389
+
67390
+ <dl class="domintro">
67391
+ <dt><var>internals</var> . <code data-x="dom-ElementInternals-shadowRoot">shadowRoot</code></dt>
67392
+ <dd><p>Returns the <code>ShadowRoot</code> for <var>internals</var>'s
67393
+ <span data-x="internals-target">target element</span>, if the
67394
+ <span data-x="internals-target">target element</span> is a <span>shadow host</span>, or null
67395
+ otherwise.</p></dd>
67396
+ </dl>
67397
+
67398
+ <div w-nodev>
67399
+ <p>The <dfn><code data-x="dom-ElementInternals-shadowRoot">shadowRoot</code></dfn> getter steps
67400
+ are:</p>
67401
+
67402
+ <ol>
67403
+ <li><p>Let <var>target</var> be <span>this</span>'s <span data-x="internals-target">target
67404
+ element</span>.</p></li>
67405
+
67406
+ <li><p>If <var>target</var> is not a <span>shadow host</span>, then return null.</p></li>
67407
+
67408
+ <li><p>Let <var>shadow</var> be <var>target</var>'s <span
67409
+ data-x="concept-element-shadow-root">shadow root</span>.</p></li>
67410
+
67411
+ <li><p>If <var>shadow</var>'s <span>available to element internals</span> is false, then return
67412
+ null.</p></li>
67413
+
67414
+ <li><p>Return <var>shadow</var>.</p></li>
67415
+ </ol>
67416
+ </div>
67417
+
67418
+ <h5>Form-associated custom elements</h5>
67419
+
67332
67420
<dl class="domintro">
67333
67421
<dt><var>internals</var> . <code data-x="dom-ElementInternals-setFormValue">setFormValue</code>(<var>value</var>)</dt>
67334
67422
<dd>
@@ -67400,89 +67488,11 @@ dictionary <dfn>ValidityStateFlags</dfn> {
67400
67488
<dd><p>Returns a <code>NodeList</code> of all the <code>label</code> elements that
67401
67489
<var>internals</var>'s <span data-x="internals-target">target element</span> is associated
67402
67490
with.</p></dd>
67403
-
67404
- <dt><var>internals</var> . <code data-x=""><a href="#dom-ElementInternals-accessibility-idl-get">role</a></code> [ = <var>value</var> ]</dt>
67405
- <dd><p>Sets or retrieves the default ARIA role for <var>internals</var>'s <span
67406
- data-x="internals-target">target element</span>, which will be used unless the page author
67407
- overrides it using the <code data-x="attr-aria-role">role</code> attribute.</p></dd>
67408
-
67409
- <dt><var>internals</var> . <code data-x=""><a href="#dom-ElementInternals-accessibility-idl-get">aria*</a></code> [ = <var>value</var> ]</dt>
67410
- <dd><p>Sets or retrieves various default ARIA states or property values for
67411
- <var>internals</var>'s <span data-x="internals-target">target element</span>, which will be used
67412
- unless the page author overrides them using the <code data-x="attr-aria-*">aria-*</code>
67413
- attributes.</p></dd>
67414
-
67415
- <dt><var>internals</var> . <code data-x="dom-ElementInternals-shadowRoot">shadowRoot</code></dt>
67416
- <dd><p>Returns the <code>ShadowRoot</code> for <var>internals</var>'s
67417
- <span data-x="internals-target">target element</span>, if the
67418
- <span data-x="internals-target">target element</span> is a <span>shadow host</span>, or null
67419
- otherwise.</p></dd>
67420
67491
</dl>
67421
67492
67422
- <p>Each <code>ElementInternals</code> has a <dfn data-x="internals-target">target element</dfn>,
67423
- which is a <span>custom element</span>. <code>ElementInternals</code> provides various operations
67424
- and attributes to allow control over internal features which the user agent provides to all
67425
- elements.</p>
67426
-
67427
- <p>Each <code>HTMLElement</code> has an <dfn>attached internals</dfn> boolean, initially
67428
- false.</p>
67429
-
67430
- <p>The <dfn><code data-x="dom-attachInternals">attachInternals()</code></dfn> method on
67431
- an <code>HTMLElement</code> <var>element</var>, when invoked, must run the following steps:</p>
67432
-
67433
- <ol>
67434
- <!-- We could lift this restriction in the future. -->
67435
- <li><p>If <var>element</var>'s <span data-x="concept-element-is-value"><code
67436
- data-x="">is</code> value</span> is not null, then throw a
67437
- <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
67438
-
67439
- <li><p>Let <var>definition</var> be the result of <span
67440
- data-x="look up a custom element definition">looking up a custom element definition</span> given
67441
- <var>element</var>'s <span>node document</span>, its namespace, its local name, and null as
67442
- <span data-x="concept-element-is-value"><code data-x="">is</code> value</span>.</p></li>
67443
-
67444
- <li><p>If <var>definition</var> is null, then throw an
67445
- <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
67446
-
67447
- <li><p>If <var>definition</var>'s <span
67448
- data-x="concept-custom-element-definition-disable-internals">disable internals</span> is true,
67449
- then throw a <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
67450
-
67451
- <li><p>If <var>element</var>'s <span>attached internals</span> is true, then throw an
67452
- <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
67453
-
67454
- <li><p>If <var>element</var>'s <span>custom element state</span> is not "<code
67455
- data-x="">precustomized</code>" or "<code data-x="">custom</code>", then throw a
67456
- <span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
67457
-
67458
- <li><p>Set <var>element</var>'s <span>attached internals</span> to true.</p></li>
67459
-
67460
- <li><p>Create a new <code>ElementInternals</code> instance
67461
- <span data-x="internals-target">targeting</span> <var>element</var>, and return it.</p></li>
67462
- </ol>
67463
-
67464
- <p>The <dfn><code data-x="dom-ElementInternals-shadowRoot">shadowRoot</code></dfn> getter steps are:
67465
-
67466
- <ol>
67467
- <li><p>Let <var>target</var> be <code>ElementInternals</code>'s <span
67468
- data-x="internals-target">target element</span>.</p></li>
67469
-
67470
- <li><p>If <var>target</var> is not a <span>shadow host</span>, then return null.</p></li>
67471
-
67472
- <li><p>Let <var>shadow</var> be <var>target</var>'s
67473
- <span data-x="concept-element-shadow-root">shadow root</span>.</p></li>
67474
-
67475
- <li><p>If <var>shadow</var>'s <span>available to element internals</span> is false, then return
67476
- null.</p></li>
67477
-
67478
- <li><p>Return <var>shadow</var>.</p></li>
67479
- </ol>
67480
-
67481
- <hr>
67482
-
67483
67493
<p>Each <span>form-associated custom element</span> has <dfn
67484
67494
data-x="face-submission-value">submission value</dfn>. It is used to provide one or more
67485
- <span data-x="formdata-entry">entries</span> on form submission, and
67495
+ <span data-x="formdata-entry">entries</span> on form submission.
67486
67496
The initial value of <span data-x="face-submission-value">submission value</span> is null, and
67487
67497
<span data-x="face-submission-value">submission value</span> can be null, a string, a
67488
67498
<code>File</code>, or a <span>list</span> of <span data-x="formdata-entry">entries</span>.</p>
@@ -67533,12 +67543,11 @@ dictionary <dfn>ValidityStateFlags</dfn> {
67533
67543
<div w-nodev>
67534
67544
67535
67545
<p>The <dfn><code data-x="dom-ElementInternals-setFormValue">setFormValue(<var>value</var>,
67536
- <var>state</var>)</code></dfn> method of the <code>ElementInternals</code> interface must
67537
- run the following steps:</p>
67546
+ <var>state</var>)</code></dfn> method steps are:</p>
67538
67547
67539
67548
<ol>
67540
- <li><p>Let <var>element</var> be this <code>ElementInternals</code >'s <span
67541
- data-x="internals-target">target element</span>.</p></li>
67549
+ <li><p>Let <var>element</var> be <span>this</span >'s <span data-x="internals-target">target
67550
+ element</span>.</p></li>
67542
67551
67543
67552
<li><p>If <var>element</var> is not a <span>form-associated custom element</span>, then throw a
67544
67553
<span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
@@ -67577,12 +67586,11 @@ dictionary <dfn>ValidityStateFlags</dfn> {
67577
67586
<dfn data-x="face-validation-anchor">validation anchor</dfn> element. It is null initially.</p>
67578
67587
67579
67588
<p>The <dfn><code data-x="dom-ElementInternals-setValidity">setValidity(<var>flags</var>,
67580
- <var>message</var>, <var>anchor</var>)</code></dfn> method of the <code>ElementInternals</code>
67581
- interface must run the following steps:</p>
67589
+ <var>message</var>, <var>anchor</var>)</code></dfn> method steps are:</p>
67582
67590
67583
67591
<ol>
67584
- <li><p>Let <var>element</var> be this <code>ElementInternals</code >'s <span
67585
- data-x="internals-target">target element</span>.</p></li>
67592
+ <li><p>Let <var>element</var> be <span>this</span >'s <span data-x="internals-target">target
67593
+ element</span>.</p></li>
67586
67594
67587
67595
<li><p>If <var>element</var> is not a <span>form-associated custom element</span>, then throw a
67588
67596
<span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>
@@ -67611,13 +67619,12 @@ dictionary <dfn>ValidityStateFlags</dfn> {
67611
67619
</ol>
67612
67620
67613
67621
<p>The <dfn><code data-x="dom-ElementInternals-validationMessage">validationMessage</code></dfn>
67614
- attribute of <code>ElementInternals</code> interface, on getting, must return the
67615
- <span data-x="face-validation-message">validation message</span> of this
67616
- <code>ElementInternals</code>'s <span data-x="internals-target">target element</span>.</p>
67622
+ getter steps are to return the <span data-x="face-validation-message">validation message</span> of
67623
+ <span>this</span>'s <span data-x="internals-target">target element</span>.</p>
67617
67624
67618
- <p>When <dfn data-x="face-entry-construction">entry construction algorithm</dfn> for a
67619
- <span>form-associated custom element</span> is invoked , given an element <var>element</var> and a
67620
- list <var>entry list</var>, run the following steps:</p>
67625
+ <p>The <dfn data-x="face-entry-construction">entry construction algorithm</dfn> for a
67626
+ <span>form-associated custom element</span>, given an element <var>element</var> and a
67627
+ list <var>entry list</var>, consists of the following steps:</p>
67621
67628
67622
67629
<ol>
67623
67630
<li>
@@ -67647,7 +67654,20 @@ dictionary <dfn>ValidityStateFlags</dfn> {
67647
67654
67648
67655
</div>
67649
67656
67650
- <hr>
67657
+ <h5>Accessibility semantics</h5>
67658
+
67659
+ <dl class="domintro">
67660
+ <dt><var>internals</var> . <code data-x=""><a href="#dom-ElementInternals-accessibility-idl-get">role</a></code> [ = <var>value</var> ]</dt>
67661
+ <dd><p>Sets or retrieves the default ARIA role for <var>internals</var>'s <span
67662
+ data-x="internals-target">target element</span>, which will be used unless the page author
67663
+ overrides it using the <code data-x="attr-aria-role">role</code> attribute.</p></dd>
67664
+
67665
+ <dt><var>internals</var> . <code data-x=""><a href="#dom-ElementInternals-accessibility-idl-get">aria*</a></code> [ = <var>value</var> ]</dt>
67666
+ <dd><p>Sets or retrieves various default ARIA states or property values for
67667
+ <var>internals</var>'s <span data-x="internals-target">target element</span>, which will be used
67668
+ unless the page author overrides them using the <code data-x="attr-aria-*">aria-*</code>
67669
+ attributes.</p></dd>
67670
+ </dl>
67651
67671
67652
67672
<p w-nohtml>By using the <code data-x="">role</code> and <code data-x="">aria*</code> properties
67653
67673
of <code>ElementInternals</code>, custom element authors can set default accessibile roles,
0 commit comments