Skip to content

Commit 52f2435

Browse files
Brian Genisiocursoragent
andcommitted
test(a11y): match full CSS property names in A9 size guards
Require a declaration boundary before the property so width/height do not match inside min-width/min-height. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0545b69 commit 52f2435

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/dom/target-size-a9.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ function ruleBody(source, selector) {
2323

2424
/** Parse a CSS length in px from a declaration value, or null. */
2525
function pxValue(body, property) {
26-
const match = body.match(new RegExp(`${property}\\s*:\\s*([^;]+);`));
26+
const escaped = property.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
27+
// Require a declaration boundary so `width` does not match inside `min-width`
28+
// (same for `height` / `min-height`).
29+
const match = body.match(
30+
new RegExp(`(?:^|[;\\n])\\s*${escaped}\\s*:\\s*([^;]+);`),
31+
);
2732
if (!match) return null;
2833
const px = String(match[1])
2934
.replace(/!important/i, '')

0 commit comments

Comments
 (0)