Skip to content

Commit

Permalink
Explain reflection in terms of setting rather than getting, explain h…
Browse files Browse the repository at this point in the history
…tmlForElement.
  • Loading branch information
Alice Boxhall committed Aug 14, 2018
1 parent 656b4a0 commit ed16f20
Showing 1 changed file with 54 additions and 47 deletions.
101 changes: 54 additions & 47 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -7312,58 +7312,67 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<p>If a reflecting IDL attribute has the type <code>HTMLElement</code>,
or an interface that descends from <code>HTMLElement</code>,
then it must be paired with another reflecting IDL attribute
that has the type <code data-x="idl-DOMString">DOMString</code>.
that has the type <code data-x="idl-DOMString">DOMString?</code>.
The relationship between these two attributes is as follows:</p>

<ol>
<li>The attribute which has the type <code>HTMLElement</code>
should be named <code data-x=""><var>attr</var>Element</code>,
where the paired <code data-x="idl-DOMString">DOMString</code> attribute is named
where the paired nullable <code data-x="idl-DOMString">DOMString</code> attribute is named
<code data-x=""><var>attr</var></code>.</li>

<li>On getting the <code data-x=""><var>attr</var></code> attribute,
the IDL attribute must return the value of the content attribute as normal.</li>
<li>On getting <code data-x=""><var>attr</var></code> attribute,
the IDL attribute must return the value of the content attribute,
or null if the content attribute does not exist on the element.</li>

<li>On getting the <code data-x=""><var>attr</var>Element</code> attribute,
it must run the following algorithm
(stopping at the first point where a value is returned):</li>
<ol>
<li>If the content attribute corresponding to <code data-x=""><var>attr</var></code>
is absent, then the IDL attribute <code data-x=""><var>attr</var>Element</code> must return null.</li>

<li>Let <var>candidate</var> be the element that the
<code data-x="dom-Document-getElementById">document.getElementById()</code> method
would find when called on the content attribute's element's <span>node document</span>
if it were passed as its argument the current value
of the corresponding content attribute.</li>

<li>If <var>candidate</var> is null, or if it is not type-compatible with the IDL attribute,
then the IDL attribute must return null.</li>
<li>On getting the <code data-x=""><var>attr</var>Element</code> IDL attribute,
it must return the value previously set for <code data-x=""><var>attr</var>Element</code>,
or null if the value was not previously set or was deleted.
</li>

<li>Otherwise, it must return <var>candidate</var>.</li>
</ol>
<li>On setting the <code data-x=""><var>attr</var></code> attribute,
the content attribute must be set to the specified value.</li>
it must run the following algorithm:
<ol>
<li>If the specified value is different from the previous value of the content attribute,
the stored value, if any, for <code data-x=""><var>attr</var>Element</code>
should be deleted.
<li>If the specified value is null, the content attribute must be removed,
and the algorithm terminated.
<li>Otherwise, the content attribute must be set to the specified value.
<li>If the specified value is not a valid value for the
<code data-x="attr-id">id</code> attribute,
the algorithm is terminated.
<li>Otherwise, let <var>candidate</var> be the element that the
<code data-x="dom-Document-getElementById">document.getElementById()</code> method
would find when called on the content attribute's element's node tree's
<span>root</span> if it were passed as its argument the current value
of the corresponding content attribute.</li>
<li>If <var>candidate</var> is not null, and it is type-compatible with the
<code data-x=""><var>attr</var>Element</code> IDL attribute,
store <var>candidate</var> as the value for the
<code data-x=""><var>attr</var>Element</code> IDL attribute.
</li>
</ol>
</li>

<li>On setting the <code data-x=""><var>attr</var>Element</code> attribute,
it must run the following algorithm:</li>
<ol>
<li>Let <var>id</var> be the empty string.</li>
<li>If the given element is not in the element's node tree,
or its light tree if it exists,
or is not type-compatible with the IDL attribute,
then remove the <code data-x=""><var>attr</var></code> and return.
<li>Otherwise, let <var>id</var> be the empty string.</li>
<li>If the given element has an <code data-x="attr-id">id</code> attribute,
and has the same <span>tree</span> as the element of the attribute being set,
and the given element is the first element in that <span>tree</span>
whose <span data-x="concept-ID">ID</span> is the value
of that <code data-x="attr-id">id</code> attribute,
then let <var>id</var> be the value of that <code data-x="attr-id">id</code> attribute.
<li>Set the <code data-x=""><var>attr</var></code> content attribute to <var>id</var>.
then let <var>id</var> be the value of that <code data-x="attr-id">id</code> attribute.</li>
<li>Set the <code data-x=""><var>attr</var></code> content attribute to <var>id</var>.</li>
</ol>
</ol>

<p>If a reflecting IDL attribute has the type <code data-x="">sequence&lt;Element&gt;</code>,
or <code data-x="">sequence&lt;<var>T</var>&gt;</code> where T descends from <code>Element</code>...</p>

<p>TODO</p>

</div>

<h4>Collections</h4>
Expand Down Expand Up @@ -43276,7 +43285,8 @@ interface <dfn>HTMLFormElement</dfn> : <span>HTMLElement</span> {
<span>HTMLConstructor</span>]
interface <dfn>HTMLLabelElement</dfn> : <span>HTMLElement</span> {
readonly attribute <span>HTMLFormElement</span>? <span data-x="dom-label-form">form</span>;
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-label-htmlFor">htmlFor</span>;
[<span>CEReactions</span>] attribute HTMLElement? <span data-x="dom-label-htmlForElement">htmlForElement</span>;
[<span>CEReactions</span>] attribute DOMString? <span data-x="dom-label-htmlFor">htmlFor</span>;
readonly attribute <span>HTMLElement</span>? <span data-x="dom-label-control">control</span>;
};</code></pre>
</dd>
Expand All @@ -43295,23 +43305,19 @@ interface <dfn>HTMLLabelElement</dfn> : <span>HTMLElement</span> {
<span>labeled control</span>.</p>

</div>

<p>The <dfn><code data-x="attr-label-for">for</code></dfn> attribute may be specified to indicate a
form control with which the caption is to be associated. If the attribute is specified, the
attribute's value must be the <span data-x="concept-id">ID</span> of a <span
data-x="category-label">labelable element</span> in the same <span>tree</span> as the
<code>label</code> element. <span w-nodev>If the attribute is specified and there is an
element in the <span>tree</span> whose <span data-x="concept-id">ID</span> is equal to the value
of the <code data-x="attr-label-for">for</code> attribute, and the first such element in
<span>tree order</span> is a <span data-x="category-label">labelable element</span>, then that
element is the <code>label</code> element's <span>labeled control</span>.</span></p>
<p>The <code data-x="dom-label-htmlForElement">htmlForElement</code> IDL attribute
may be specified to indicate a
form control with which the caption is to be associated.
If the attribute is specified, the attribute's value must be a
<span data-x="category-label">labelable element</span>.
</p>

<div w-nodev>

<p>If the <code data-x="attr-label-for">for</code> attribute is not specified, but the
<code>label</code> element has a <span data-x="category-label">labelable element</span> descendant,
then the first such descendant in <span>tree order</span> is the <code>label</code> element's
<span>labeled control</span>.</p>
<p>If the <code data-x="dom-label-htmlForElement">htmlForElement</code> IDL attribute is not specified, but
the <code>label</code> element has a <span data-x="category-label">labelable element</span>
descendant, then the first such descendant in <span>tree order</span> is the <code>label</code>
element's <span>labeled control</span>.</p>

<p>The <code>label</code> element's exact default presentation and behavior, in particular what
its <span>activation behavior</span> might be, if anything, should match the platform's label
Expand Down Expand Up @@ -43375,8 +43381,9 @@ interface <dfn>HTMLLabelElement</dfn> : <span>HTMLElement</span> {

<div w-nodev>

<p>The <dfn><code data-x="dom-label-htmlFor">htmlFor</code></dfn> IDL attribute must
<span>reflect</span> the <code data-x="attr-label-for">for</code> content attribute.</p>
<p>The paired <dfn><code data-x="dom-label-htmlFor">htmlFor</code></dfn> and
<dfn><code data-x="dom-label-htmlForElement">htmlForElement</code></dfn> IDL attributes must
<span>reflect</span> the <dfn><code data-x="attr-label-for">for</code></dfn> content attribute.</p>

<p>The <dfn><code data-x="dom-label-control">control</code></dfn> IDL attribute must return the
<code>label</code> element's <span>labeled control</span>, if any, or null if there isn't one.</p>
Expand Down

0 comments on commit ed16f20

Please sign in to comment.