Repository navigation
fix(rules): hidden-text applies a style rule with a comment in its selector #684 - #874
Conversation
797e2df to
6f7bd28
Compare
…lector #684 Comments are dropped from a style rule's selector before it is judged, as a browser's tokenizer does, so a section comment before a plain class rule no longer makes it read as complex. A comment between two name characters still separates them. Measured on a 7,061-page corpus: no page's finding changed. Signed-off-by: Nik Cubrilovic <[email protected]>
6f7bd28 to
4d0f2a3
Compare
|
Reviewed the diff. I didn't run the tests. I found no correctness, security or performance problems; the change is small and well scoped.
|
…ANGELOG line #684 Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review triage (4d0f2a3), fixed in 5d50167: the |
|
Reviewed the diff for PR 874 (
The docs and changelog entries match the behaviour. |
Closes #684.
What changes
content/hidden-text's rule scanner skipped CSS comments while looking for a rule's{, but kept them in the selector text. So/* Section */ .b{display:none}was not a bare class selector: it was treated as complex and only marked.bas ambiguous, and the plainly hidden text went unreported. A browser drops comments while tokenizing and applies the rule.stripComments()inpackages/rules/src/shared/css-tokens.ts. It removes comments the way a tokenizer does, copying quoted strings and escapes through untouched. The rule scanner runs a style rule's prelude through it before judging the selector..a+ comment +breads.a b, a complex (ambiguous) selector, never the class.ab. Codex found that case..a /* x */ .bis still a descendant selector, and[title="/* x */"].bis still complex: a/*inside a string is text.Corpus measurement (the issue's last criterion)
The measurement ran
content/hidden-textbefore (main'shidden-text.tsandcss-tokens.ts) and after this change over the 7,061 HTML pages of the dom-classifier corpus snapshot (/Volumes/BACKUP/dom-classifier-data/2026-09-22/live-snapshot/content-store.db, read-only). Only pages with a<style>element and a/*in the HTML can change, and there are 660 of them. Results on those 660: 604 pass, 50 warn, 1 fail, 5 skipped. 0 pages changed status or item count. I re-ran it on the final code with the same result. So the fix brings back the issue's case without moving results on real pages in this corpus.Tests
packages/rules/tests/hidden-text-css-comments-684.test.ts, which fails before the change. It covers:{and inside the selector;.a /* x */ .band.a/**/.bstaying ambiguous;.a/**/band#a/**/bnot becoming.ab/#ab, with an#abcontrol;hidden-text.test.ts(155 tests).test-suites.ts --check,tangly check --strictand the detect-secrets hook pass.Docs and skill
rules/content/hidden-text: says comments are dropped from selectors.