Skip to content

Commit 04ad8f7

Browse files
committed
[wip] fix: support parsing */ expressions without surrounding spaces
fixes #138
1 parent 5aea4d7 commit 04ad8f7

File tree

5 files changed

+993
-0
lines changed

5 files changed

+993
-0
lines changed

lib/ValuesParser.js

+2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ module.exports = class ValuesParser extends Parser {
148148

149149
if (Punctuation.chars.includes(type)) {
150150
Punctuation.fromTokens(tokens, this);
151+
} else if (type === 'word' && Operator.compact.test(value)) {
152+
Operator.fromTokens(tokens, this);
151153
} else if (Func.test(tokens)) {
152154
Func.fromTokens(tokens, this);
153155
} else if (this.options.interpolation && Interpolation.test(tokens, this)) {

lib/nodes/Operator.js

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const Node = require('./Node');
1414

1515
const operators = ['+', '-', '/', '*', '%', '=', '<=', '>=', '<', '>'];
1616
const operRegex = new RegExp(`([/|*}])`);
17+
const compactRegex = /^\*\b/;
1718

1819
class Operator extends Node {
1920
constructor(options) {
@@ -33,6 +34,10 @@ class Operator extends Node {
3334
return operRegex;
3435
}
3536

37+
static get compact() {
38+
return compactRegex;
39+
}
40+
3641
static tokenize(tokens, parser) {
3742
const [first, ...rest] = tokens;
3843
const [, value, startLine, , endLine, endChar] = first;

test/fixtures/func.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
'lCH(40% 68.8 34.5 / 50%)',
3030
'hwb(90deg 0% 0% / 0.5)',
3131
'calc(-0.5 * var(foo))',
32+
'calc(var(--foo)*var(--bar))',
3233
'calc(1px + -2vw - 4px)',
3334
'calc(((768px - 100vw) / 2) - 15px)',
3435
'bar(baz(black, 10%), 10%)',

0 commit comments

Comments
 (0)