From 1488bb6f765e41558bb221dc247012a35d88527b Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Tue, 7 Jun 2016 09:08:31 -0400 Subject: [PATCH] Make :target definition sticky based on last scroll-to-fragment 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. --- source | 61 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/source b/source index 1969c687326..f4821dee743 100644 --- a/source +++ b/source @@ -67660,6 +67660,16 @@ Demos: +
:target
+ +
+ +

For the purposes of the CSS :target + pseudo-class, the Document's target elements are a list + containing the Document's target element, if it is + not null, or containing no elements, if it is.

+ +
:enabled
@@ -68000,10 +68010,6 @@ Demos: -

Another section of this specification defines the target element used with the :target - pseudo-class.

-

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

    +
  1. If there is no indicated part of the + document, set the Document's target element to null.

  2. -
  3. Let target be the indicated part of the - document, as defined below.

  4. +
  5. +

    If the indicated part of the + document is the top of the document, then:

    -
  6. If target is the top of the document, then scroll to the - beginning of the document for the Document, and abort these steps.

  7. +
      +
    1. Set the Document's target element to null.

    2. -
    3. Use the scroll an element into view algorithm to scroll target into view, with the align to top flag set.

    4. +
    5. Scroll to the beginning of the document for the Document.

    6. +
    + -
  8. Run the focusing steps for that element, with the Document's - viewport as the fallback target.

  9. +
  10. +

    Otherwise:

    -
  11. Move the sequential focus navigation starting point to target.

    +
      +
    1. Let target be element that is the indicated part of the + document.

    2. + +
    3. Set the Document's target element to + target.

    4. + +
    5. Use the scroll an element into view algorithm to scroll target + into view, with the align to top flag set.

    6. + +
    7. Run the focusing steps for target, with the + Document's viewport as the fallback target.

    8. +
    9. Move the sequential focus navigation starting point to + target.

      +
    +

The indicated part of the document is the one that the 1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O data-x="XML MIME type">XML MIME types is the responsibility of RFC7303).

+

There is also a target element for each Document, which is used in + defining the :target pseudo-class and is updated by the + above algorithm. It is initially null.

+

For HTML documents (and HTML MIME types), the following processing model must be followed to determine what the indicated part of the document is.

@@ -82633,12 +82664,6 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O -

For the purposes of the interaction of HTML with Selectors' :target pseudo-class, the - target element is the indicated part of the document, if that is an - element; otherwise there is no target element. -

-

The task source for the task mentioned in this section must be the DOM manipulation task source.