Repository navigation
Anchor the alternation in the :link and :placeholder-shown tests - #181
Merged
Merged
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
jdalton
added a commit
that referenced
this pull request
Sep 17, 2026
Consolidated commits: - a959b4a Fix the forgiving fallback and EOF-terminated arguments Original author: John-David Dalton <john.david.dalton@gmail.com> - 8a91824 Anchor the alternation in the :link and :placeholder-shown tests Original author: John-David Dalton <john.david.dalton@gmail.com> - efa85cb Answer an id selector from the id map instead of walking Original author: John-David Dalton <john.david.dalton@gmail.com> - 538f744 Merge pull request #179 from jdalton/fix/forgiving-and-eof Original author: Diego Perini <diego.perini@gmail.com> - c545320 Establish shared legacy runtime initialization Original author: jdalton <john.david.dalton@gmail.com> - 5d68c9b Merge pull request #197 from jdalton/refactor/legacy-runtime-init Original author: John-David Dalton <jdalton@users.noreply.github.com> - ec4bcf3 Merge pull request #181 from jdalton/fix/link-precedence Original author: Diego Perini <diego.perini@gmail.com> - fe15bc3 Merge pull request #183 from jdalton/perf/id-lookup Original author: John-David Dalton <jdalton@users.noreply.github.com> - d7e01ee Add a jsdom selector-engine adapter Original author: jdalton <john.david.dalton@gmail.com> - 62d45eb Merge pull request #211 from jdalton/feat/jsdom-adapter Original author: John-David Dalton <jdalton@users.noreply.github.com>
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.