Repository navigation
fix: don't match anything for empty ~= attribute value - #1916
NevanDeCoteau wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Fixes #1910
Per the CSS spec, [a~=""] matches nothing. css-select matched elements with an empty value and values with leading, trailing or doubled spaces, because an empty value produced a regex that matches the empty string.
This change makes the ~= rule return falseFunc for an empty value, the same way it already does for values containing whitespace.
Tests added to test/attributes.ts:
[foo~=''] compiles to falseFunc
[a~=""] matches none of the four elements from the issue
[a~="x"] still matches whole words
I confirmed the new tests fail without the fix. The full test suite and lint pass locally.
Summary by CodeRabbit
~=with an empty value now correctly match no elements. Existing selectors with non-empty values continue to work.