Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore how to specify referenceTarget's effect on ID lookups #10987

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 98 additions & 56 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -5128,7 +5128,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
</div>



<h4>Keywords and enumerated attributes</h4>

<p>Some attributes, called <dfn data-x="enumerated attribute" data-lt="enumerated attribute"
Expand Down Expand Up @@ -5187,6 +5186,85 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
</ul>


<h4>Element reference attributes</h4>

<p><dfn data-x="element reference" data-lt="element reference" export>
Element reference</dfn> attributes refer to one or more Elements in the document.</p>

<p>The steps to <dfn export data-x="resolve-the-reference-target">resolve the reference
target</dfn> on an element <var>element</var> referred to by an element reference attribute
are:</p>

<ol>
<li><p>If <var>element</var> does not have a <span>shadow root</span>, or <var>element</var>'s
<span>shadow root</span> doesn't have a <code data-x="">referenceTarget</code>
property, return <var>element</var>.</p></li>

<li><p>Let <var>referenceTarget</var> be the value of <var>element</var>'s <span>shadow
root</span>'s <code data-x="">referenceTarget</code> property</p></li>

<li><p>Let <var>candidate</var> be the first element in <var>element</var>'s <span>shadow
root</span> whose <span data-x="concept-id">ID</span> matches <var>referenceTarget</var>.</p>
</li>

<li><p>If no such element exists, return null.</p></li>

<li><p>Return the result of <span data-x="resolve-the-reference-target">resolving the reference
target</span> on <var>candidate</var>.
</p></li>
</ol>

<h5>Single element reference attributes</h5>

<p><dfn data-x="single element reference attribute" data-lt="single element reference attribute"
export>Single element reference attributes</dfn> refer to a single Element.</p>

<p>The rules to <dfn export data-x="get the attr-associated element">get the
<var>attr</var>-associated element</dfn> for an element reference attribute <var>attr</var> and
element <var>element</var>, are:</p>

<ol>
<li><p>If the attribute is not specified on <var>element</var>, return null.</p></li>

<li>
<p>If <var>element</var> has an <span data-x="explicitly set attr-element">explicitly-set
<var>attr</var>-element</span> which is not null:</p>

<ol>
<li><p>If <var>element</var>'s <span data-x="explicitly set attr-element">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 let
<var>candidate</var> be <var>element</var>'s
<span data-x="explicitly set attr-element">explicitly-set <var>attr</var>-element</span>.</p>
</li>

<li><p>Otherwise, let <var>candidate</var> be null.</p></li>
</ol>

</li>

<li>
<p>Otherwise:

<ol>
<li><p>Let <var>value</var> be the attribute value.</p></li>

<li><p>Let <var>candidate</var> be the first element in <var>element</var>'s <span>tree</span>,
in <span>tree order</span> whose <span data-x="concept-id">ID</span> is <var>value</var>.</p>
</li>

<li><p>If no such element exists, let <var>candidate</var> be null.</p>
</li>
</ol>
</li>

<li>If candidate is null, return null.</li>

<li><p>Return the result of <span data-x="resolve-the-reference-target">resolving the reference
target</span> on <var>candidate</var>.
</p></li>
</ol>


<h4>Numbers</h4>

Expand Down Expand Up @@ -8519,59 +8597,23 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
name</span>:</p>

<ul>
<li><p>Its <span>reflected target</span> has 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>Its <span>reflected target</span> has an <dfn export data-x="explicitly set attr-element">
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>Its <span>reflected target</span> <var>reflectedTarget</var> has a <dfn
for="Element,ElementInternals" export id="attr-associated-element">get the
<var>attr</var>-associated element</dfn> algorithm, that runs these steps:</p>
<p>The getter steps are:</p>

<ol>
<li><p>Let <var>element</var> be the result of running <var>reflectedTarget</var>'s <span>get
the element</span>.</p></li>

<li><p>Let <var>contentAttributeValue</var> be the result of running
<var>reflectedTarget</var>'s <span>get the content attribute</span>.</p></li>

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

<ol>
<li><p>If <var>reflectedTarget</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>reflectedTarget</var>'s <span>explicitly set <var>attr</var>-element</span>.</p></li>

<li><p>Return null.</p></li>
</ol>
<li><p>Let <var>candidate</var> be the result of running <span>this</span>'s
<span data-x="get the attr-associated element">get the <var>attr</var>-associated
element</span>.</p>
</li>

<li>
<p>Otherwise, if <var>contentAttributeValue</var> is not null, return the first element
<var>candidate</var>, in <span>tree order</span>, that meets the following criteria:</p>

<ul>
<li><p><var>candidate</var>'s <span>root</span> is the same as <var>element</var>'s
<span>root</span>;</p></li>

<li><p><var>candidate</var>'s <span data-x="concept-ID">ID</span> is
<var>contentAttributeValue</var>; and</p></li>

<li><p><var>candidate</var> <span>implements</span> <var>T</var>.</p></li>
</ul>

<p>If no such element exists, then return null.</p>
</li>

<li><p>Return null.</p></li>
<li><p>Return the result of <span data-x="dom-retarget">retargeting</span> <var>candidate</var>
against <var>this</var>.</p></li>
</ol>
</li>

<li><p>The getter steps are to return the result of running <span>this</span>'s <span>get the
<var>attr</var>-associated element</span>.</p></li>
<li>

<li>
<p>The setter steps are:</p>
Expand Down Expand Up @@ -8817,10 +8859,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
</ul>

<p>For those, specification authors must use the <span>reflected target</span>'s
<span>get the <var>attr</var>-associated element</span> and <span>get the
<var>attr</var>-associated elements</span>, respectively. The content attribute presence and value
must not be used as they cannot be fully synchronized with the <span>reflected IDL
attribute</span>.</p>
<span data-x="get the attr-associated element">get the <var>attr</var>-associated element</span>
and <span>get the <var>attr</var>-associated elements</span>, respectively. The content attribute
presence and value must not be used as they cannot be fully synchronized with the <span>reflected
IDL attribute</span>.</p>

<p>A <span>reflected target</span>'s <span>explicitly set <var>attr</var>-element</span>,
<span>explicitly set <var>attr</var>-elements</span>, <span>cached <var>attr</var>-associated
Expand Down Expand Up @@ -46424,11 +46466,11 @@ interface <dfn interface>HTMLLabelElement</dfn> : <span>HTMLElement</span> {
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>
<code>label</code> element. <span w-nodev>If the attribute is specified, the <span
data-x="get the attr-associated element">for-associated element</span> is not null, and the <span
data-x="get the attr-associated element">for-associated element</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>

<div w-nodev>

Expand Down