fix: css variables and scss interpolation (#4471)

This commit is contained in:
Evilebot Tnawi authored and GitHub committed 2018-05-12 22:38:28 +03:00
1 parent 2f5c00ad18
commit bc2f57dcf9
3 files changed
+50 -1

No files matched your search

+6 -1
View File
@@ -452,7 +452,7 @@ function genericPrint(path, options, print) {
const isNextRightCurlyBrace =
iNextNode.type === "value-word" && iNextNode.value === "}";
// Ignore interpolation in SCSS (i.e. ``#{variable}``)
// Ignore interpolation in SCSS (i.e. `#{variable}`)
if (
isHash ||
isLeftCurlyBrace ||
@@ -465,6 +465,11 @@ function genericPrint(path, options, print) {
continue;
}
// Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
if (iNode.value === "--" && iNextNode.value === "#") {
continue;
}
const isNextHash =
iNextNode.type === "value-word" && iNextNode.value === "#";
@@ -28,3 +28,34 @@ exports[`variables.css 1`] = `
}
`;
exports[`variables.scss 1`] = `
.foo {
--#{$prop}: 10px;
#{$prop}: 10px;
prop1: var(--#{$var});
prop2: var(#{$var}, --my-#{$var}, pink);
prop3: calc(var(--#{$var}) * 1px);
}
@supports (--#{$prop}: green) {
body {
color: var(--#{$var});
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.foo {
--#{$prop}: 10px;
#{$prop}: 10px;
prop1: var(--#{$var});
prop2: var(#{$var}, --my-#{$var}, pink);
prop3: calc(var(--#{$var}) * 1px);
}
@supports (--#{$prop}: green) {
body {
color: var(--#{$var});
}
}
`;
+13
View File
@@ -0,0 +1,13 @@
.foo {
--#{$prop}: 10px;
#{$prop}: 10px;
prop1: var(--#{$var});
prop2: var(#{$var}, --my-#{$var}, pink);
prop3: calc(var(--#{$var}) * 1px);
}
@supports (--#{$prop}: green) {
body {
color: var(--#{$var});
}
}