Re: [csswg-drafts] [selectors] Match local links (#2010)

Thank you!  There are two things I'm seeking clarification on: one is about how the feature works, and the second is a process question about whether the `selectors-4` spec supersedes `selectors-5`.

The use-case relates to table-of-contents hyperlinks, and it would be convenient to use CSS selectors to choose hyperlinks where the browser can remain within the current document (simply scrolling/moving to the hyperlink fragment if it is present, or top of the page for same-document links that have no fragment).

Given that the spec here (`S4`) changed to _include_ anchor equality in the comparison -- from the original (deferred to `S5`) where it did not -- my sense about the hyperlink-matching logic specified in each would work for a hypothetical scenario is:

```
Browser location:   index.html#toc-item-2
CSS selector:       a:local-link

Selected?
 S5 S4      Anchor Target (a href)
----------------------------------
[x] [ ]     index.html
[x] [x]     index.html#toc-item-2
[x] [ ]     index.html#toc-item-5
```

(I place S5 before S4 in the column to reflect their chronological publication order)

In the use case I'm investigating, the S5 behaviour initially seems like what is required - a way to select links that should not require the browser to navigate to a different page.

In terms of compatibility, it feels to me that S5 in combination with the `:target` pseudo-selector could provide the results specified by S4 -- a selector of `a:local-link:target`, for example, to describe links that are to the current document and that are also the current browser navigation location.

I can't see an equivalent compatibility route if S4 is implemented first -- it selects fewer items, and so there is not a way to expand that out to achieve the S5 results.

-- 
GitHub Notification of comment by jayaddison
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2010#issuecomment-2241780319 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Sunday, 21 July 2024 21:31:09 UTC