Skip to content

Commit 9a77222

Browse files
committed
Update parseNumber()
1 parent b2ebbb9 commit 9a77222

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

lib/parsers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ exports.parseNumber = function parseNumber(val) {
138138
return val;
139139
case exports.TYPES.NUMBER:
140140
return `${parseFloat(val)}`;
141+
case exports.TYPES.CALC:
142+
return cssCalc(val, {
143+
format: 'specifiedValue',
144+
});
141145
default:
142146
return undefined;
143147
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
],
3838
"main": "./lib/CSSStyleDeclaration.js",
3939
"dependencies": {
40-
"@asamuzakjp/css-color": "^3.1.4",
40+
"@asamuzakjp/css-color": "^3.1.5",
4141
"rrweb-cssom": "^0.8.0"
4242
},
4343
"devDependencies": {

test/parsers.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,13 @@ describe('parseNumber', () => {
328328

329329
assert.strictEqual(output, '0.5');
330330
});
331+
332+
it('should return calculated value', () => {
333+
let input = 'calc(2 / 3)';
334+
let output = parsers.parseLength(input);
335+
336+
assert.strictEqual(output, 'calc(0.666667)');
337+
});
331338
});
332339

333340
describe('parseLength', () => {

0 commit comments

Comments
 (0)