Strip every /* … */ comment from a CSS string, so a text-level selector
scan reads declarations only. Without this, a wrapped prose line inside a
comment (e.g. one starting with the word "body") looks exactly like a
top-level selector to the line-anchored patterns in
library-css-scope.test.ts.
Single pass over the source rather than a /\*[\s\S]*?\*/ replace, so
comments and quoted strings are recognised in the order they actually
appear. A plain regex is wrong in both directions: content: "/*" would
open a comment that swallows the following (real) rules, and scanning for
strings first would trip over the apostrophes this codebase's own prose
comments are full of. Strings are copied through verbatim — a CSS string
cannot span a raw newline, so an unterminated quote ends at the line break
instead of eating the rest of the file.
Strip every
/* … */comment from a CSS string, so a text-level selector scan reads declarations only. Without this, a wrapped prose line inside a comment (e.g. one starting with the word "body") looks exactly like a top-level selector to the line-anchored patterns in library-css-scope.test.ts.Single pass over the source rather than a
/\*[\s\S]*?\*/replace, so comments and quoted strings are recognised in the order they actually appear. A plain regex is wrong in both directions:content: "/*"would open a comment that swallows the following (real) rules, and scanning for strings first would trip over the apostrophes this codebase's own prose comments are full of. Strings are copied through verbatim — a CSS string cannot span a raw newline, so an unterminated quote ends at the line break instead of eating the rest of the file.