fix: css variables and scss interpolation (#4471)

master
Evilebot Tnawi 2018-05-12 22:38:28 +03:00 committed by GitHub
parent 2f5c00ad18
commit bc2f57dcf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 1 deletions

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 === "#";

View File

@ -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});
}
}
`;

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});
}
}