Anchor the alternation in the :link and :placeholder-shown tests - #181
Open
jdalton wants to merge 1 commit into
Open
Anchor the alternation in the :link and :placeholder-shown tests#181jdalton wants to merge 1 commit into
jdalton wants to merge 1 commit into
Conversation
jdalton
force-pushed
the
fix/link-precedence
branch
from
September 4, 2026 18:00
bbdec0e to
52dfea1
Compare
/^a|area$/ alternates '^a' with 'area$' rather than anchoring an alternation, so it accepts any element whose name begins with 'a'. ':link' and ':any-link' therefore match <abbr href="...">, where browsers match only <a> and <area>. It agrees with browsers on those two, which is why the test suites do not catch it. /^input|textarea$/ in ':placeholder-shown' has the same shape; there the surrounding conditions happen to mask it. The link test is hoisted into a helper at the same time, so the three places that need it share one definition. References: - Spec: https://drafts.csswg.org/selectors-4/#the-any-link-pseudo — ':any-link' matches an a or area element with an href - Spec: https://html.spec.whatwg.org/#selector-placeholder-shown — ':placeholder-shown', for the pattern of the same shape - Chromium: https://github.com/chromium/chromium/blob/155.0.8041.1/third_party/blink/renderer/core/css/selector_checker.cc#L2550 — ':any-link' is one IsLink() predicate - Chromium: https://github.com/chromium/chromium/blob/155.0.8041.1/third_party/blink/renderer/core/css/selector_checker.cc#L2553 — ':link' is the same predicate, unvisited - MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/:any-link
jdalton
force-pushed
the
fix/link-precedence
branch
from
September 5, 2026 02:47
52dfea1 to
8a91824
Compare
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/^a|area$/alternates^awitharea$rather than anchoring an alternation, so:linkand:any-linkmatch any element whose name begins witha,<abbr href>among them./^input|textarea$/in:placeholder-shownhas the same shape.Detail, and how it was checked
/^a|area$/reads as^aorarea$, so it accepts any element whose name begins witha.:linkand:any-linktherefore match<abbr href="...">, where browsers match only<a>and<area>. It agrees with browsers on those two, which is why the test suites do not catch it./^input|textarea$/in:placeholder-shownhas the same shape; there the surrounding conditions happen to mask it.The link test is hoisted into a helper at the same time, so the three places that need it share one definition.
Extracted from #167 as a standalone change: one file, applies to master on its own, and checked against a fixture to confirm it fixes what it describes and moves nothing else.
References: the spec, the browser source, and what each part was reasoned from
This patch applies to master on its own. The sixteen in this series were checked by cherry-picking them onto master one after another, in this order and in reverse, and all sixteen land without a conflict.
:any-linkmatches anaorareaelement with anhref.:placeholder-shown, for the pattern of the same shape.selector_checker.cc#L2550—:any-linkis oneIsLink()predicate.selector_checker.cc#L2553—:linkis the same predicate, unvisited.:any-link.