You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An attribute selector with an operator ([a^=v], [a$=v], [a*=v], [a~=v], [a|=v], with i/s flags) now keeps its attribute in the rule's subject. A rule such as .is-open [id$="-drawer"] { display:none !important } reaches only elements that have the attribute with a value that could satisfy it, not every element including <html>. Any other [name…] form (an unread value) still requires its attribute by name. A namespaced or escaped name narrows nothing.
couldMatch now compares attribute values (ASCII case-insensitive, a superset of a browser's match) for = and each operator, so .is-open [id="drawer"] no longer makes an <input id="q"> unconfirmed. Operator selectors stay undecidable: an element that can satisfy one stays unconfirmed, never hidden or shown. Two edge cases from the codex pass are covered: HTML attributes aK and ak are distinct (either may satisfy the test), and a literal NUL in a value (U+FFFD in a browser) is not ruled out.
Tests
New page-styles-attr-operators-984.test.ts (parser cases, the issue's repro table through aria-command-name and form-labels, matching and non-matching values per operator, edge shapes) and 15 Chromium-rendered rows in static-hidden-chromium.json. 24 of the new tests fail against the old source. Docs: solution text of the a11y naming rules and the button-name and aria-hidden-focus pages mention operator selectors; tangly check --strict passes.
Reviewed the diff, mainly packages/rules/src/shared/page-styles.ts. I didn't run the tests or check CI.
I found no correctness or security problems. The narrowing in couldMatch stays a superset of what a browser matches, so it can only turn "unconfirmed" into a decision where the old code was already over-conservative. The cases I traced:
Values are compared ASCII case-insensitively.
An empty value never matches for ^=, $=, *= and ~=.
A ~= value containing whitespace never matches.
Escaped or unquoted-with-escape values, and namespaced names, fall back to presence-only or nothing.
NUL and U+FFFD are treated as possible matches.
aK and ak are both tried.
(low) page-styles.tscouldMatch: it now runs Array.from(view.el.attributes) for every attribute test on every element for every uncertain rule. On a large DOM with many uncertain rules that allocates a lot. Reading the attributes once per ElementView, or only when the attribute test has an operator, would avoid it.
(nit) readOperatorAttr: the i/s flag directly after an unquoted identifier value ([a=b i]) relies on the whitespace before the flag. A test for [a=bi] (no flag) would pin that down. If it already exists in the new test file, ignore this.
(nit) The long solution strings are duplicated across 7 rules. A shared constant would keep them from drifting, though that matches the existing style.
Test coverage is good: parser cases, per-operator match and non-match, and Chromium-rendered fixtures.
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
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.
What
An attribute selector with an operator (
[a^=v],[a$=v],[a*=v],[a~=v],[a|=v], withi/sflags) now keeps its attribute in the rule's subject. A rule such as.is-open [id$="-drawer"] { display:none !important }reaches only elements that have the attribute with a value that could satisfy it, not every element including<html>. Any other[name…]form (an unread value) still requires its attribute by name. A namespaced or escaped name narrows nothing.couldMatchnow compares attribute values (ASCII case-insensitive, a superset of a browser's match) for=and each operator, so.is-open [id="drawer"]no longer makes an<input id="q">unconfirmed. Operator selectors stay undecidable: an element that can satisfy one stays unconfirmed, never hidden or shown. Two edge cases from the codex pass are covered: HTML attributesaKandakare distinct (either may satisfy the test), and a literal NUL in a value (U+FFFD in a browser) is not ruled out.Tests
New
page-styles-attr-operators-984.test.ts(parser cases, the issue's repro table througharia-command-nameandform-labels, matching and non-matching values per operator, edge shapes) and 15 Chromium-rendered rows instatic-hidden-chromium.json. 24 of the new tests fail against the old source. Docs:solutiontext of the a11y naming rules and the button-name and aria-hidden-focus pages mention operator selectors;tangly check --strictpasses.Closes #984
skills: no change