Skip to content

Commit c9a6a88

Browse files
committed
Fix case with variable and several color values
1 parent 3da426b commit c9a6a88

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = postcss.plugin('postcss-extract-value', function (opts) {
88
var reColorKeywords = new RegExp(colorNameList.join('|'));
99
var reCheck = new RegExp(/#\w+|rgba?|hsla?/.source +
1010
'|' + reColorKeywords.source, 'g');
11-
var reCSSVariable = /var\(-{2}\w{1}[\w+-]*/;
11+
var reCSSVariable = /^var\(-{2}\w{1}[\w+-]*/;
1212
var reHex = /#(\w{6}|\w{3})/;
1313
var reRgb = /rgba?\([\d,.\s]+\)/;
1414
var reHls = /hsla?\(\s?[0-9]{1,3},\s?(([0-9]{1,3})+%,\s?){2}[0-9.]+\s?\)/;

test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,22 @@ test('default value in css variable', t => {
161161
}`;
162162
return run(t, input, output, { onlyColor: true });
163163
});
164+
165+
test('variable with several color values', t => {
166+
let input = `:root {
167+
--base-color: #fff;
168+
}
169+
.foo {
170+
border: 1px solid var(--base-color),
171+
2px solid #000;
172+
}`;
173+
let output = `:root {
174+
--base-color: #fff;
175+
--border-1: #000;
176+
}
177+
.foo {
178+
border: 1px solid var(--base-color),
179+
2px solid var(--border-1);
180+
}`;
181+
return run(t, input, output, { onlyColor: true });
182+
});

0 commit comments

Comments
 (0)