Skip to content

Commit 3419d36

Browse files
authored
Rewrite output element to not use non-existing observers
The output element was defined to use descendant observers, which do not exist in all implementations and are not grounded in a specification concept. Thankfully, it can also be written to not require those. Tests: web-platform-tests/wpt#16080. Fixes #4163.
1 parent 77240a2 commit 3419d36

File tree

1 file changed

+48
-51
lines changed

1 file changed

+48
-51
lines changed

source

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3193,7 +3193,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
31933193
<li>The <dfn data-x="concept-slot" data-x-href="https://dom.spec.whatwg.org/#concept-slot">slot</dfn> concept, and its <dfn data-x="slot-name" data-x-href="https://dom.spec.whatwg.org/#slot-name">name</dfn> and <dfn data-x-href="https://dom.spec.whatwg.org/#slot-assigned-nodes">assigned nodes</dfn></li>
31943194
<li>The <dfn data-x="finding flattened slotables" data-x-href="https://dom.spec.whatwg.org/#find-flattened-slotables">find flattened slotables</dfn> algorithm</li>
31953195
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#assign-a-slot">assign a slot</dfn> algorithm</li>
3196-
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-node-pre-insert">pre-insert</dfn>, <dfn data-x="concept-node-insert" data-x-href="https://dom.spec.whatwg.org/#concept-node-insert">insert</dfn>, <dfn data-x="concept-node-append" data-x-href="https://dom.spec.whatwg.org/#concept-node-append">append</dfn>, <dfn data-x="concept-node-replace" data-x-href="https://dom.spec.whatwg.org/#concept-node-replace">replace</dfn>, <dfn data-x="concept-node-replace-all" data-x-href="https://dom.spec.whatwg.org/#concept-node-replace-all">replace all</dfn>, <dfn data-x="concept-node-remove" data-x-href="https://dom.spec.whatwg.org/#concept-node-remove">remove</dfn>, and <dfn data-x="concept-node-adopt" data-x-href="https://dom.spec.whatwg.org/#concept-node-adopt">adopt</dfn> algorithms for nodes</li>
3196+
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-node-pre-insert">pre-insert</dfn>, <dfn data-x="concept-node-insert" data-x-href="https://dom.spec.whatwg.org/#concept-node-insert">insert</dfn>, <dfn data-x="concept-node-append" data-x-href="https://dom.spec.whatwg.org/#concept-node-append">append</dfn>, <dfn data-x="concept-node-replace" data-x-href="https://dom.spec.whatwg.org/#concept-node-replace">replace</dfn>, <dfn data-x="concept-node-replace-all" data-x-href="https://dom.spec.whatwg.org/#concept-node-replace-all">replace all</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#string-replace-all">string replace all</dfn>, <dfn data-x="concept-node-remove" data-x-href="https://dom.spec.whatwg.org/#concept-node-remove">remove</dfn>, and <dfn data-x="concept-node-adopt" data-x-href="https://dom.spec.whatwg.org/#concept-node-adopt">adopt</dfn> algorithms for nodes</li>
31973197
<li>The <dfn data-x="concept-node-insert-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-insert-ext">insertion steps</dfn>,
31983198
<dfn data-x="concept-node-remove-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-remove-ext">removing steps</dfn>,
31993199
<dfn data-x="concept-node-adopt-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-adopt-ext">adopting steps</dfn>, and
@@ -3203,6 +3203,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
32033203
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-element-attribute">attribute list</dfn> concept</li>
32043204
<li>The <dfn data-x="concept-cd-data" data-x-href="https://dom.spec.whatwg.org/#concept-cd-data">data</dfn> of a text node</li>
32053205
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-child-text-content">child text content</dfn> of a node</li>
3206+
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-descendant-text-content">descendant text content</dfn> of a node</li>
32063207
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-event"><code>Event</code></dfn> interface</li>
32073208
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-eventtarget"><code>EventTarget</code></dfn> interface</li>
32083209
<li>The <!--en-GB--><dfn id="activation-behaviour" data-x-href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior">activation behavior</dfn> hook</li>
@@ -51653,89 +51654,85 @@ interface <dfn>HTMLOutputElement</dfn> : <span>HTMLElement</span> {
5165351654

5165451655
<div w-nodev>
5165551656

51656-
<p>The element has a <dfn data-x="concept-output-mode">value mode flag</dfn> which is either <i
51657-
data-x="concept-output-mode-value">value</i> or <i
51658-
data-x="concept-output-mode-default">default</i>. Initially, the <span
51659-
data-x="concept-output-mode">value mode flag</span> must be set to <i
51660-
data-x="concept-output-mode-default">default</i>.</p>
51657+
<p>The element has a <dfn data-x="concept-output-default-value-override">default value
51658+
override</dfn> (null or a string). Initially it must be null.</p>
5166151659

51662-
<p>The element also has a <dfn data-x="concept-output-defaultValue">default value</dfn>.
51663-
Initially, the <span data-x="concept-output-defaultValue">default value</span> must be the empty
51664-
string.</p>
51660+
<p>The element's <dfn data-x="concept-output-default-value">default value</dfn> is determined by
51661+
the following steps:</p>
5166551662

51666-
<p>When the <span data-x="concept-output-mode">value mode flag</span> is in mode <dfn><i
51667-
data-x="concept-output-mode-default">default</i></dfn>, the contents of the element represent both
51668-
the value of the element and its <span data-x="concept-output-defaultValue">default value</span>.
51669-
When the <span data-x="concept-output-mode">value mode flag</span> is in mode <dfn><i
51670-
data-x="concept-output-mode-value">value</i></dfn>, the contents of the element represent the
51671-
value of the element only, and the <span data-x="concept-output-defaultValue">default value</span>
51672-
is only accessible using the <code data-x="dom-output-defaultValue">defaultValue</code> IDL
51673-
attribute.</p>
51663+
<ol>
51664+
<li><p>If this element's <span data-x="concept-output-default-value-override">default value
51665+
override</span> is non-null, then return it.</p></li>
5167451666

51675-
<p>Whenever the element's descendants are changed in any way, if the <span
51676-
data-x="concept-output-mode">value mode flag</span> is in mode <i
51677-
data-x="concept-output-mode-default">default</i>, the element's <span
51678-
data-x="concept-output-defaultValue">default value</span> must be set to the value of the
51679-
element's <code>textContent</code> IDL attribute.</p>
51667+
<li><p>Return this element's <span>descendant text content</span>.</p></li>
51668+
</ol>
5168051669

5168151670
<p>The <span data-x="concept-form-reset-control">reset algorithm</span> for <code>output</code>
51682-
elements is to set the element's <span data-x="concept-output-mode">value mode flag</span> to <i
51683-
data-x="concept-output-mode-default">default</i> and then to set the element's
51684-
<code>textContent</code> IDL attribute to the value of the element's <span
51685-
data-x="concept-output-defaultValue">default value</span> (thus replacing the element's child
51686-
nodes).</p>
51671+
elements is to run these steps:
51672+
51673+
<ol>
51674+
<li><p><span>String replace all</span> with this element's <span
51675+
data-x="concept-output-default-value">default value</span> within this element.</p></li>
51676+
51677+
<li><p>Set this element's <span data-x="concept-output-default-value-override">default value
51678+
override</span> to null.</p></li>
51679+
</ol>
5168751680

5168851681
</div>
5168951682

5169051683
<dl class="domintro">
51691-
5169251684
<dt><var>output</var> . <code subdfn data-x="dom-output-value">value</code> [ = <var>value</var> ]</dt>
51693-
5169451685
<dd>
51695-
5169651686
<p>Returns the element's current value.</p>
5169751687

5169851688
<p>Can be set, to change the value.</p>
51699-
5170051689
</dd>
5170151690

5170251691
<dt><var>output</var> . <code subdfn data-x="dom-output-defaultValue">defaultValue</code> [ = <var>value</var> ]</dt>
51703-
5170451692
<dd>
51705-
5170651693
<p>Returns the element's current default value.</p>
5170751694

5170851695
<p>Can be set, to change the default value.</p>
51709-
5171051696
</dd>
5171151697

5171251698
<dt><var>output</var> . <code subdfn data-x="dom-output-type">type</code></dt>
51713-
5171451699
<dd>
51715-
5171651700
<p>Returns the string "<code data-x="">output</code>".</p>
51717-
5171851701
</dd>
51719-
5172051702
</dl>
5172151703

5172251704
<div w-nodev>
5172351705

51724-
<p>The <dfn><code data-x="dom-output-value">value</code></dfn> IDL attribute must act like the
51725-
element's <code>textContent</code> IDL attribute, except that on setting, in addition, before the
51726-
child nodes are changed, the element's <span data-x="concept-output-mode">value mode flag</span>
51727-
must be set to <i data-x="concept-output-mode-value">value</i>.</p>
51706+
<p>The <dfn><code data-x="dom-output-value">value</code></dfn> attribute's getter must return this
51707+
element's <span>descendant text content</span>.</p>
51708+
51709+
<p>The <code data-x="dom-output-value">value</code> attribute's setter must run these steps:</p>
51710+
51711+
<ol>
51712+
<li><p>Set this element's <span data-x="concept-output-default-value-override">default value
51713+
override</span> to its <span data-x="concept-output-default-value">default value</span>.</p></li>
51714+
51715+
<li><p><span>String replace all</span> with the given value within this element.</p></li>
51716+
</ol>
51717+
51718+
<p>The <dfn><code data-x="dom-output-defaultValue">defaultValue</code></dfn> attribute's getter
51719+
must return the result of running this element's <span
51720+
data-x="concept-output-default-value">default value</span>.</p>
51721+
51722+
<p>The <code data-x="dom-output-defaultValue">defaultValue</code> attribute's setter must run
51723+
these steps:</p>
51724+
51725+
<ol>
51726+
<li><p>If this element's <span data-x="concept-output-default-value-override">default value
51727+
override</span> is null, then <span>string replace all</span> with the given value within this
51728+
element and return.</p></li>
5172851729

51729-
<p>The <dfn><code data-x="dom-output-defaultValue">defaultValue</code></dfn> IDL attribute, on
51730-
getting, must return the element's <span data-x="concept-output-defaultValue">default
51731-
value</span>. On setting, the attribute must set the element's <span
51732-
data-x="concept-output-defaultValue">default value</span>, and, if the element's <span
51733-
data-x="concept-output-mode">value mode flag</span> is in the mode <i
51734-
data-x="concept-output-mode-default">default</i>, set the element's <code>textContent</code> IDL
51735-
attribute as well.</p>
51730+
<li><p>Set this element's <span data-x="concept-output-default-value-override">default value
51731+
override</span> to the given value.</p></li>
51732+
</ol>
5173651733

51737-
<p>The <dfn><code data-x="dom-output-type">type</code></dfn> attribute must return the string
51738-
"<code data-x="">output</code>".</p>
51734+
<p>The <dfn><code data-x="dom-output-type">type</code></dfn> attribute's getter must return "<code
51735+
data-x="">output</code>".</p>
5173951736

5174051737
<p>The <dfn><code data-x="dom-output-htmlFor">htmlFor</code></dfn> IDL attribute must
5174151738
<span>reflect</span> the <code data-x="attr-output-for">for</code> content attribute.</p>

0 commit comments

Comments
 (0)