Skip to content

Commit cac6f39

Browse files
Fix: Ignore calc-size from detection (#230)
* Add failing test * Ensure Regex ignores calc-size
1 parent bbedb09 commit cac6f39

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/lib/transform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { parser } = require('../parser.js');
77
const reducer = require('./reducer.js');
88
const stringifier = require('./stringifier.js');
99

10-
const MATCH_CALC = /((?:-(moz|webkit)-)?calc)/i;
10+
const MATCH_CALC = /((?:-(moz|webkit)-)?calc(?!-))/i;
1111

1212
/**
1313
* @param {string} value

test/index.js

+17
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ function testCss(fixture, expected, opts = {}) {
3030
};
3131
}
3232

33+
function testCssDoesNotThrow(fixture, expected, opts = {}) {
34+
return async () => {
35+
const result = await postcss(reduceCalc(opts)).process(
36+
fixture,
37+
postcssOpts
38+
);
39+
assert.strictEqual(result.css, expected);
40+
const warnings = result.warnings();
41+
assert.strictEqual(warnings.length, 0);
42+
};
43+
}
44+
3345
function testThrows(fixture, expected, warning, opts = {}) {
3446
fixture = `foo{bar:${fixture}}`;
3547
expected = `foo{bar:${expected}}`;
@@ -970,6 +982,11 @@ test(
970982
testValue('calc(1px + 2unknown)', 'calc(1px + 2unknown)')
971983
);
972984

985+
test(
986+
'calc-size should be ignored',
987+
testCssDoesNotThrow('.foo{block-size: calc-size(auto, size)}', '.foo{block-size: calc-size(auto, size)}')
988+
);
989+
973990
test(
974991
'error with parsing',
975992
testThrows(

0 commit comments

Comments
 (0)