Skip to content

Commit

Permalink
Add reflect target
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Nov 16, 2022
1 parent d59405f commit f0363a4
Showing 1 changed file with 49 additions and 53 deletions.
102 changes: 49 additions & 53 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -7539,11 +7539,13 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

<h4>Reflecting content attributes in IDL attributes</h4>

<p>IDL attributes of elements and <code>ElementInternals</code> objects can be defined to
<p>IDL attributes of <span data-x="reflect target">reflect targets</span> can be defined to
<dfn>reflect</dfn> a particular content attribute. This means that on getting, the IDL attribute
returns the current value of the content attribute, and on setting, the IDL attribute changes the
value of the content attribute to the given value.</p>

<p>A <dfn>reflect target</dfn> is an element or <code>ElementInternals</code> object.</p>

<div w-nodev>

<p>In general, on getting, if the content attribute is not present, the IDL attribute must act as
Expand All @@ -7559,8 +7561,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<code>ElementInternals</code> objects as their <span data-x="internals-target">target
element</span>'s <span>native accessibility semantics map</span> cannot be directly manipulated
and as such reflection is only happening in a single direction. This approach was nevertheless
chosen to make it less error-prone to define IDL attributes shared between <code>Element</code>
and <code>ElementInternals</code> objects.</p>
chosen to make it less error-prone to define IDL attributes shared between <span data-x="reflect
target">reflect targets</span>.</p>

<p>IDL attributes of type <code data-x="idl-DOMString">DOMString</code> or <code data-x=""><span
data-x="idl-DOMString">DOMString</span>?</code> that reflect <span data-x="enumerated
Expand Down Expand Up @@ -7794,40 +7796,38 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
interface that inherits from <code>Element</code>, then:

<ul>
<li><p>Elements and <code>ElementInternals</code> objects of the type this IDL attribute appears
on have an <dfn>explicitly set <var>attr</var>-element</dfn>, which is a weak reference to an
element or null. It is initially null.</p></li>
<li><p><span data-x="reflect target">Reflect targets</span> of the type this IDL attribute
appears on have an <dfn>explicitly set <var>attr</var>-element</dfn>, which is a weak reference
to an element or null. It is initially null.</p></li>

<li>
<p>Elements and <code>ElementInternals</code> objects of the type this IDL attribute appears on
have an <dfn for="Element,ElementInternals" export><var>attr</var>-associated element</dfn>. To
compute the <span><var>attr</var>-associated element</span> for such an element or
<code>ElementInternals</code> object <var>elementOrElementInternals</var>:</p>
<p><span data-x="reflect target">Reflect targets</span> of the type this IDL attribute appears
on have an <dfn for="Element,ElementInternals" export><var>attr</var>-associated element</dfn>.
To compute the <span><var>attr</var>-associated element</span> for such a <span>reflect
target</span> <var>reflectTarget</var>:</p>

<ol>
<li><p>Let <var>element</var> be <var>elementOrElementInternals</var> if it is an element;
otherwise <var>elementOrElementInternals</var>'s <span data-x="internals-target">target
element</span>.</p></li>
<li><p>Let <var>element</var> be <var>reflectTarget</var> if it is an element; otherwise
<var>reflectTarget</var>'s <span data-x="internals-target">target element</span>.</p></li>

<li>
<p>If <var>elementOrElementInternals</var>'s <span>explicitly set
<var>attr</var>-element</span> is not null:</p>
<p>If <var>reflectTarget</var>'s <span>explicitly set <var>attr</var>-element</span> is not
null:</p>

<ul>
<li><p>If <var>elementOrElementInternals</var>'s <span>explicitly set
<var>attr</var>-element</span> is a <span>descendant</span> of any of <var>element</var>'s
<span data-x="concept-shadow-including-ancestor">shadow-including ancestors</span>, then
return <var>elementOrElementInternals</var>'s <span>explicitly set
<var>attr</var>-element</span>.</p></li>
<li><p>If <var>reflectTarget</var>'s <span>explicitly set <var>attr</var>-element</span> is a
<span>descendant</span> of any of <var>element</var>'s <span
data-x="concept-shadow-including-ancestor">shadow-including ancestors</span>, then return
<var>reflectTarget</var>'s <span>explicitly set <var>attr</var>-element</span>.</p></li>

<li><p>Return null.</p></li>
</ul>
</li>

<li>
<p>Otherwise, if the content attribute is present on <var>elementOrElementInternals</var>,
then return the first element <var>candidate</var>, in <span>tree order</span>, that meets the
following criteria:</p>
<p>Otherwise, if the content attribute is present on <var>reflectTarget</var>, return the
first element <var>candidate</var>, in <span>tree order</span>, that meets the following
criteria:</p>

<ul class="brief">
<li><var>candidate</var>'s <span>root</span> is the same as <var>element</var>'s
Expand All @@ -7844,11 +7844,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
</ol>

<p class="note">Other parts of this specification, or other specifications using attribute
reflection, are expected to consult an element or <code>ElementInternals</code> object's
<span><var>attr</var>-associated element</span>. An element or <code>ElementInternals</code>
object's <span>explicitly set <var>attr</var>-element</span> is an internal implementation
detail of its <span><var>attr</var>-associated element</span> and is not to be used
directly.</p>
reflection, are expected to consult a <span>reflect target</span>'s
<span><var>attr</var>-associated element</span>. A <span>reflect target</span>'s
<span>explicitly set <var>attr</var>-element</span> is an internal implementation detail of its
<span><var>attr</var>-associated element</span> and is not to be used directly.</p>
</li>

<li><p>The getter steps are to return <span>this</span>'s <span><var>attr</var>-associated
Expand Down Expand Up @@ -7899,41 +7898,39 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

<!-- TODO: indentation here is wrong -->
<ul>
<li><p>Elements and <code>ElementInternals</code> objects of the type this IDL attribute appears
<li><p><span data-x="reflect target">Reflect targets</span> of the type this IDL attribute appears
on have <dfn>explicitly set <var>attr</var>-elements</dfn>, which is either a <span>list</span> of
weak references to elements or null. It is initially null.</p></li>

<li><p>Elements and <code>ElementInternals</code> objects of the type this IDL attribute appears
<li><p><span data-x="reflect target">Reflect targets</span> of the type this IDL attribute appears
on have <dfn>cached <var>attr</var>-associated elements</dfn>, which is a <code
data-x="">FrozenArray&lt;<var>T</var>&gt;?</code>. It is initially null.</p></li>

<li>
<p>Elements and <code>ElementInternals</code> objects of the type this IDL attribute appears on
<p><span data-x="reflect target">Reflect targets</span> of the type this IDL attribute appears on
have <dfn for="Element,ElementInternals" export><var>attr</var>-associated elements</dfn>. To
compute the <span><var>attr</var>-associated elements</span> for such an element or
<code>ElementInternals</code> object <var>elementOrElementInternals</var>:</p>
compute the <span><var>attr</var>-associated elements</span> for such a <span>reflect
target</span> <var>reflectTarget</var>:</p>

<ol>
<li><p>Let <var>elements</var> be an empty <span>list</span>.</p></li>

<li><p>Let <var>element</var> be <var>elementOrElementInternals</var> if it is an element;
otherwise <var>elementOrElementInternals</var>'s <span data-x="internals-target">target
element</span>.</p></li>
<li><p>Let <var>element</var> be <var>reflectTarget</var> if it is an element; otherwise
<var>reflectTarget</var>'s <span data-x="internals-target">target element</span>.</p></li>

<li>
<p>If <var>elementOrElementInternals</var>'s <span>explicitly set
<var>attr</var>-elements</span> is not null, then:</p>
<p>If <var>reflectTarget</var>'s <span>explicitly set <var>attr</var>-elements</span> is not
null:</p>

<ol>
<li>
<p><span data-x="list iterate">For each</span> <var>attrElement</var> in the
<var>elementOrElementInternals</var>'s <span>explicitly set
<var>attr</var>-elements</span>:</p>
<p><span data-x="list iterate">For each</span> <var>attrElement</var> in
<var>reflectTarget</var>'s <span>explicitly set <var>attr</var>-elements</span>:</p>

<ol>
<li><p>If <var>attrElement</var> is not a <span>descendant</span> of any of <var>element</var>'s <span
data-x="concept-shadow-including-ancestor">shadow-including ancestors</span>, then
<span>continue</span>.</p></li>
<li><p>If <var>attrElement</var> is not a <span>descendant</span> of any of
<var>element</var>'s <span data-x="concept-shadow-including-ancestor">shadow-including
ancestors</span>, then <span>continue</span>.</p></li>

<li><p><span data-x="list append">Append</span> <var>attrElement</var> to <var>elements</var>.</p></li>
</ol>
Expand All @@ -7944,8 +7941,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>
<p>Otherwise:</p>
<ol>
<li><p>If the content attribute is not present on <var>elementOrElementInternals</var>, then
return null.</p></li>
<li><p>If the content attribute is not present on <var>reflectTarget</var>, then return
null.</p></li>

<li><p>Let <var>tokens</var> be the content attribute's value, <span data-x="split a string on
ASCII whitespace">split on ASCII whitespace</span>.
Expand Down Expand Up @@ -7979,13 +7976,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
</ol>

<p class="note">Other parts of this specification, or other specifications using attribute
reflection, are expected to consult an element or <code>ElementInternals</code> object's
<span><var>attr</var>-associated elements</span>. An element or <code>ElementInternals</code>
object's <span>explicitly set <var>attr</var>-elements</span> is an internal implementation
detail of its <span><var>attr</var>-associated elements</span> and is not to be used directly.
Similarly, the element or <code>ElementInternals</code> object's <span>cached
<var>attr</var>-associated elements</span> is an internal implementation detail of the IDL
attribute's getter.</p>
reflection, are expected to consult a <span>reflect target</span>'s
<span><var>attr</var>-associated elements</span>. A <span>reflect target</span>'s
<span>explicitly set <var>attr</var>-elements</span> is an internal implementation detail of its
<span><var>attr</var>-associated elements</span> and is not to be used directly. Similarly, a
<span>reflect target</span>'s <span>cached <var>attr</var>-associated elements</span> is an
internal implementation detail of the IDL attribute's getter.</p>
</li>

<!-- TODO: indentation here is wrong -->
Expand Down

0 comments on commit f0363a4

Please sign in to comment.