Skip to content

Commit

Permalink
Make :target definition sticky based on last scroll-to-fragment
Browse files Browse the repository at this point in the history
Fixes #190. As discussed there, Gecko, WebKit, and Blink all save the
last-scrolled-to element as what matches :target.

Also moves :target's definition to live alongside the rest of the
pseudo-classes, referencing the target element concept from the
navigation section.
  • Loading branch information
domenic committed Jun 7, 2016
1 parent 270b5f3 commit 1488bb6
Showing 1 changed file with 43 additions and 18 deletions.
61 changes: 43 additions & 18 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -67660,6 +67660,16 @@ Demos:

</dd>

<dt><dfn data-noexport=""><code data-x="selector-target">:target</code></dfn></dt>

<dd>

<p>For the purposes of the CSS <code data-x="selector-focus">:target</code>
<span>pseudo-class</span>, the <code>Document</code>'s <i>target elements</i> are a list
containing the <code>Document</code>'s <span>target element</span>, if it is
not null, or containing no elements, if it is. <ref spec=SELECTORS></p>

</dd>

<dt><dfn data-noexport=""><code data-x="selector-enabled">:enabled</code></dfn></dt>

Expand Down Expand Up @@ -68000,10 +68010,6 @@ Demos:

</dl>

<p class="note">Another section of this specification defines the <i data-x="target
element">target element</i> used with the <code data-x="selector-target">:target</code>
<span>pseudo-class</span>.</p>

<p class="note">This specification does not define when an element matches the <code undefined
data-x="selector-lang()">:lang()</code> dynamic <span>pseudo-class</span>, as it is defined in
sufficient detail in a language-agnostic fashion in the Selectors specification.
Expand Down Expand Up @@ -82569,20 +82575,41 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
user agent must do nothing. The aforementioned algorithm is as follows:</p>

<ol>
<li><p>If there is no <span data-x="the indicated part of the document">indicated part of the
document</span>, set the <code>Document</code>'s <span>target element</span> to null.</p></li>

<li><p>Let <var>target</var> be <span>the indicated part of the
document</span>, as defined below.</p></li>
<li>
<p>If the <span data-x="the indicated part of the document">indicated part of the
document</span> is the top of the document, then:</p>

<li><p>If <var>target</var> is the top of the document, then <span>scroll to the
beginning of the document</span> for the <code>Document</code>, and abort these steps. <ref spec=CSSOMVIEW></p></li>
<ol>
<li><p>Set the <code>Document</code>'s <span>target element</span> to null.</p></li>

<li><p>Use the <span>scroll an element into view</span> algorithm to scroll <var>target</var> into view, with the <var>align to top flag</var> set. <ref spec=CSSOMVIEW></p></li>
<li><p><span>Scroll to the beginning of the document</span> for the <code>Document</code>. <ref
spec=CSSOMVIEW></p></li>
</ol>
</li>

<li><p>Run the <span>focusing steps</span> for that element, with the <code>Document</code>'s
<span>viewport</span> as the <i>fallback target</i>.</p></li>
<li>
<p>Otherwise:</p>

<li><p>Move the <span>sequential focus navigation starting point</span> to <var>target</var>.</p>
<ol>
<li><p>Let <var>target</var> be element that is <span>the indicated part of the
document</span>.</p></li>

<li><p>Set the <code>Document</code>'s <span>target element</span> to
<var>target</var>.</p></li>

<li><p>Use the <span>scroll an element into view</span> algorithm to scroll <var>target</var>
into view, with the <var>align to top flag</var> set. <ref spec=CSSOMVIEW></p></li>

<li><p>Run the <span>focusing steps</span> for <var>target</var>, with the
<code>Document</code>'s <span>viewport</span> as the <i>fallback target</i>.</p></li>

<li><p>Move the <span>sequential focus navigation starting point</span> to
<var>target</var>.</p>
</ol>
</li>
</ol>

<p><dfn>The indicated part of the document</dfn> is the one that the <span
Expand All @@ -82593,6 +82620,10 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
data-x="XML MIME type">XML MIME types</span> is the responsibility of RFC7303). <ref
spec=RFC7303></p>

<p>There is also a <dfn>target element</dfn> for each <code>Document</code>, which is used in
defining the <code data-x="selector-target">:target</code> pseudo-class and is updated by the
above algorithm. It is initially null.</p>

<p>For HTML documents (and <span data-x="HTML MIME type">HTML MIME types</span>), the following
processing model must be followed to determine what <span>the indicated part of the
document</span> is.</p>
Expand Down Expand Up @@ -82633,12 +82664,6 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O

</ol>

<p>For the purposes of the interaction of HTML with Selectors' <dfn data-noexport=""><code
data-x="selector-target">:target</code></dfn> <span>pseudo-class</span>, the
<dfn><i>target element</i></dfn> is <span>the indicated part of the document</span>, if that is an
element; otherwise there is no <i data-x="target element">target element</i>.
<ref spec=SELECTORS></p>

<p>The <span>task source</span> for the task mentioned in this section must be the <span>DOM
manipulation task source</span>.</p>

Expand Down

0 comments on commit 1488bb6

Please sign in to comment.