Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { parser } = require('../parser.js');
const reducer = require('./reducer.js');
const stringifier = require('./stringifier.js');

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

/**
* @param {string} value
Expand Down
17 changes: 17 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ function testCss(fixture, expected, opts = {}) {
};
}

function testCssDoesNotThrow(fixture, expected, opts = {}) {
return async () => {
const result = await postcss(reduceCalc(opts)).process(
fixture,
postcssOpts
);
assert.strictEqual(result.css, expected);
const warnings = result.warnings();
assert.strictEqual(warnings.length, 0);
};
}

function testThrows(fixture, expected, warning, opts = {}) {
fixture = `foo{bar:${fixture}}`;
expected = `foo{bar:${expected}}`;
Expand Down Expand Up @@ -970,6 +982,11 @@ test(
testValue('calc(1px + 2unknown)', 'calc(1px + 2unknown)')
);

test(
'calc-size should be ignored',
testCssDoesNotThrow('.foo{block-size: calc-size(auto, size)}', '.foo{block-size: calc-size(auto, size)}')
);

test(
'error with parsing',
testThrows(
Expand Down
Loading