Skip to content

Commit

Permalink
Rewrite output element to not use non-existing observers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
annevk committed Apr 3, 2019
1 parent 77240a2 commit 3419d36
Showing 1 changed file with 48 additions and 51 deletions.
99 changes: 48 additions & 51 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3193,7 +3193,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<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>
<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>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#assign-a-slot">assign a slot</dfn> algorithm</li>
<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>
<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>
<li>The <dfn data-x="concept-node-insert-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-insert-ext">insertion steps</dfn>,
<dfn data-x="concept-node-remove-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-remove-ext">removing steps</dfn>,
<dfn data-x="concept-node-adopt-ext" data-x-href="https://dom.spec.whatwg.org/#concept-node-adopt-ext">adopting steps</dfn>, and
Expand All @@ -3203,6 +3203,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-element-attribute">attribute list</dfn> concept</li>
<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>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-child-text-content">child text content</dfn> of a node</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-descendant-text-content">descendant text content</dfn> of a node</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-event"><code>Event</code></dfn> interface</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-eventtarget"><code>EventTarget</code></dfn> interface</li>
<li>The <!--en-GB--><dfn id="activation-behaviour" data-x-href="https://dom.spec.whatwg.org/#eventtarget-activation-behavior">activation behavior</dfn> hook</li>
Expand Down Expand Up @@ -51653,89 +51654,85 @@ interface <dfn>HTMLOutputElement</dfn> : <span>HTMLElement</span> {

<div w-nodev>

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

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

<p>When the <span data-x="concept-output-mode">value mode flag</span> is in mode <dfn><i
data-x="concept-output-mode-default">default</i></dfn>, the contents of the element represent both
the value of the element and its <span data-x="concept-output-defaultValue">default value</span>.
When the <span data-x="concept-output-mode">value mode flag</span> is in mode <dfn><i
data-x="concept-output-mode-value">value</i></dfn>, the contents of the element represent the
value of the element only, and the <span data-x="concept-output-defaultValue">default value</span>
is only accessible using the <code data-x="dom-output-defaultValue">defaultValue</code> IDL
attribute.</p>
<ol>
<li><p>If this element's <span data-x="concept-output-default-value-override">default value
override</span> is non-null, then return it.</p></li>

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

<p>The <span data-x="concept-form-reset-control">reset algorithm</span> for <code>output</code>
elements is to set the element's <span data-x="concept-output-mode">value mode flag</span> to <i
data-x="concept-output-mode-default">default</i> and then to set the element's
<code>textContent</code> IDL attribute to the value of the element's <span
data-x="concept-output-defaultValue">default value</span> (thus replacing the element's child
nodes).</p>
elements is to run these steps:

<ol>
<li><p><span>String replace all</span> with this element's <span
data-x="concept-output-default-value">default value</span> within this element.</p></li>

<li><p>Set this element's <span data-x="concept-output-default-value-override">default value
override</span> to null.</p></li>
</ol>

</div>

<dl class="domintro">

<dt><var>output</var> . <code subdfn data-x="dom-output-value">value</code> [ = <var>value</var> ]</dt>

<dd>

<p>Returns the element's current value.</p>

<p>Can be set, to change the value.</p>

</dd>

<dt><var>output</var> . <code subdfn data-x="dom-output-defaultValue">defaultValue</code> [ = <var>value</var> ]</dt>

<dd>

<p>Returns the element's current default value.</p>

<p>Can be set, to change the default value.</p>

</dd>

<dt><var>output</var> . <code subdfn data-x="dom-output-type">type</code></dt>

<dd>

<p>Returns the string "<code data-x="">output</code>".</p>

</dd>

</dl>

<div w-nodev>

<p>The <dfn><code data-x="dom-output-value">value</code></dfn> IDL attribute must act like the
element's <code>textContent</code> IDL attribute, except that on setting, in addition, before the
child nodes are changed, the element's <span data-x="concept-output-mode">value mode flag</span>
must be set to <i data-x="concept-output-mode-value">value</i>.</p>
<p>The <dfn><code data-x="dom-output-value">value</code></dfn> attribute's getter must return this
element's <span>descendant text content</span>.</p>

<p>The <code data-x="dom-output-value">value</code> attribute's setter must run these steps:</p>

<ol>
<li><p>Set this element's <span data-x="concept-output-default-value-override">default value
override</span> to its <span data-x="concept-output-default-value">default value</span>.</p></li>

<li><p><span>String replace all</span> with the given value within this element.</p></li>
</ol>

<p>The <dfn><code data-x="dom-output-defaultValue">defaultValue</code></dfn> attribute's getter
must return the result of running this element's <span
data-x="concept-output-default-value">default value</span>.</p>

<p>The <code data-x="dom-output-defaultValue">defaultValue</code> attribute's setter must run
these steps:</p>

<ol>
<li><p>If this element's <span data-x="concept-output-default-value-override">default value
override</span> is null, then <span>string replace all</span> with the given value within this
element and return.</p></li>

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

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

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

0 comments on commit 3419d36

Please sign in to comment.