Skip to content

Commit

Permalink
Fill in details for reflecting DOMString as an awkward example
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Dec 15, 2022
1 parent 52c57d6 commit 25e5809
Showing 1 changed file with 61 additions and 33 deletions.
94 changes: 61 additions & 33 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -7596,21 +7596,26 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<p><span data-x="reflected target">Reflected targets</span> have these associated algorithms:

<ul class="brief">
<li><dfn>get the element</dfn>: takes no arguments, returns an element</li>
<li><dfn>get the content attribute</dfn>: takes no arguments, returns null or a string.</li>
<li><dfn>set the content attribute</dfn>: takes a string <var>value</var>, returns nothing.</li>
<li><dfn>delete the content attribute</dfn>: takes no arguments, returns nothing.</li>
</ul>

<p>For elements these are defined as follows:
<p>For a <span>reflected target</span> that is an element <var>element</var> these are defined as
follows:</p>

<dl>
<dt><span>get the element</span></dt>
<dd><p>Return <var>element</var>.</p></dd>

<dt><span>get the content attribute</span></dt>
<dd>
<ol>
<li><p>Let <var>attribute</var> be the result of running <span
data-x="concept-element-attributes-get-by-namespace">get an attribute by namespace and local
name</span> given null, the <span>reflected content attribute</span>, and the <span>reflected
target</span>.</p></li>
name</span> given null, the <span>reflected content attribute</span>, and
<var>element</var>.</p></li>

<li><p>If <var>attribute</var> is null, then return null.</p></li>

Expand All @@ -7619,27 +7624,47 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
</ol>
</dd>

<dt><span>set the content attribute</span> with a string <var>value</var>
<dt><span>set the content attribute</span> with a string <var>value</var></dt>
<dd><p><span data-x="concept-element-attributes-set-value">Set an attribute value</span> given
the <span>reflected target</span>, the <span>reflected content attribute</span>, and
<var>value</var>.
<var>element</var>, the <span>reflected content attribute</span>, and <var>value</var>.</p></dd>

<dt><span>delete the content attribute</span>
<dt><span>delete the content attribute</span></dt>
<dd><p><span data-x="concept-element-attributes-remove-by-namespace">Remove an attribute by
namespace and local name</span> given null, the <span>reflected content attribute</span>, and the
<span>reflected target</span>.</p></dd>
namespace and local name</span> given null, the <span>reflected content attribute</span>, and
<var>element</var>.</p></dd>
</dl>

<hr>
<p>For a <span>reflected target</span> that is an <code>ElementInternals</code> object
<var>elementInternals</var> these are defined as follows:</p>

<dl>
<dt><span>get the element</span></dt>
<dd><p>Return <var>elementInternals</var>'s <span data-x="internals-target">target
element</span>.</p></dd>

<dt><span>get the content attribute</span></dt>
<dd>
<ol>
<li><p>If <var>elementInternals</var>'s <span data-x="internals-target">target element</span>'s
<span>native accessibility semantics map</span>[the <span>reflected content attribute</span>]
<span data-x="map exists">does not exist</span>, then return null.

<li><p>Return <var>elementInternals</var>'s <span data-x="internals-target">target
element</span>'s <span>native accessibility semantics map</span>[the <span>reflected content
attribute</span>].</p></li>
</ol>
</dd>

<p>In general, on getting, if the content attribute is not present, the IDL attribute must act as
if the content attribute's value is the empty string; and on setting, if the content attribute is
not present, it must first be added.</p>
<dt><span>set the content attribute</span> with a string <var>value</var></dt>
<dd><p><span data-x="map set">Set</span> <var>elementInternals</var>'s <span
data-x="internals-target">target element</span>'s <span>native accessibility semantics
map</span>[the <span>reflected content attribute</span>] to <var>value</var>.</p></dd>

<p>For <code>ElementInternals</code> objects the content attributes are the <span data-x="map
key">keys</span> of their <span data-x="internals-target">target element</span>'s <span>native
accessibility semantics map</span>. Any manipulation of content attributes as part of the
<span>reflect</span> algorithms ends up impacting that map accordingly.</p>
<dt><span>delete the content attribute</span></dt>
<dd><p><span data-x="map remove">Remove</span> <var>elementInternals</var>'s <span
data-x="internals-target">target element</span>'s <span>native accessibility semantics
map</span>[the <span>reflected content attribute</span>].</p></dd>
</dl>

<p class="note">This results in somewhat redundant data structures for
<code>ElementInternals</code> objects as their <span data-x="internals-target">target
Expand All @@ -7648,6 +7673,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
chosen to make it less error-prone to define IDL attributes shared between <span data-x="reflected
target">reflected targets</span>.</p>

<hr>

<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
attribute">enumerated</span> content attributes can be <dfn>limited to only known values</dfn>.
Expand All @@ -7662,30 +7689,31 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

<ol>
<li>
<p>If the content attribute is an <span>enumerated attribute</span>, and the IDL attribute is
<span>limited to only known values</span>:</p>
<p>If the attribute defined for the <span>reflected target</span>'s <span>get the
element</span>, with namespace null and local name <span>reflected content attribute</span>,
is an <span>enumerated attribute</span>, and the <span>reflected IDL attribute</span> of the
<span>reflected object</span> is <span>limited to only known values</span>:</p>
<!-- This is super awkward... -->

<ol>
<li><p>If the content attribute is not in any state (e.g., the attribute is missing and there
is no <i data-x="missing value default">missing value default</i>), or the content attribute
is in a state with no associated keyword value, then return the empty string.</p></li>

<li><p>Return the <span>canonical keyword</span> for the state of the content
attribute.</p></li>
<li><p>If the <span>reflected target</span>'s <span>get the content attribute</span> is not
in any state (e.g., the return value is null and there is no <i data-x="missing value
default">missing value default</i>), or the content attribute is in a state with no
associated keyword value, then return the empty string.</p></li>
<!-- Less awkward, but still not great. -->

<li><p>Return the <span>canonical keyword</span> for the state of the <span>reflected
target</span>'s <span>get the content attribute</span>.</p></li>
</ol>
</li>

<li>
<p>Otherwise:</p>

<ol>
<li><p>Return the content attribute's value.</p></li>
</ol>
</li>
<li><p>Return the <span>reflected target</span>'s <span>get the content
attribute</span>.</p></li>
</ol>
</li>

<li><p>The setter steps are to set the content attribute's value to the given value.</p></li>
<li><p>The setter steps are to run the <span>reflected target</span>'s <span>set the content
attribute</span> with the given value.</p></li>
</ul>

<p>If a reflecting IDL attribute has the type <code data-x=""><span
Expand Down

0 comments on commit 25e5809

Please sign in to comment.