This repository was archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
This repository was archived by the owner on Jul 24, 2024. It is now read-only.
rgb and rgba functions misinterpret CSS variables as a single value instead of their output #2251
Copy link
Copy link
Open
Labels
Milestone
Description
Example:
:root { --color--text: 18, 18, 26; }
body { color: rgba(var(--color--text), 0.8); }
Expected outcome:
body {
color: rgba(18, 18, 26, 0.8);
}
Actual outcome:
When using rgba():
{
"status": 1,
"file": "/path/to/partial.scss",
"line": 30,
"column": 23,
"message": "argument `$color` of `rgba($color, $alpha)` must be a color\n\nBacktrace:\n\tsrc/scss/elements/_projectTeaser.scss:30, in function `rgba`\n\tsrc/scss/elements/_projectTeaser.scss:30",
"formatted": "Error: argument `$color` of `rgba($color, $alpha)` must be a color\n\n Backtrace:\n \tsrc/scss/elements/_projectTeaser.scss:30, in function `rgba`\n \tsrc/scss/elements/_projectTeaser.scss:30\n on line 30 of src/scss/elements/_projectTeaser.scss\n>> background-color: rgba(var(--color--fadePrimary), 0.8);\n ----------------------^\n"
}
When using rgb(), without the alpha-value:
{
"status": 1,
"file": "/path/to/partial.scss",
"line": 30,
"column": 23,
"message": "Function rgb is missing argument $green.",
"formatted": "Error: Function rgb is missing argument $green.\n on line 30 of src/scss/elements/_projectTeaser.scss\n>> background-color: rgb(var(--color--fadePrimary));\n ----------------------^\n"
}
Notes:
This works if I wrap the CSS variable values in their own rgb() function and just output those as property values, but in order to add different alpha-values on the fly, storing only the R, G, and B values in variables is a lot more flexible.
As I posted this on Twitter and instantly got a backlash: please note that of course I could use $sass-variables instead, but CSS variables are a lot better to work with for obvious reasons (mutability, element scoping).
Versions:
- NPM version (`npm -v`): 5.6.0
- Node version (`node -v`): 6.10.2
- Node Process (`node -p process.versions`):
{ http_parser: '2.7.0',
node: '6.10.2',
v8: '5.1.281.98',
uv: '1.9.1',
zlib: '1.2.11',
ares: '1.10.1-DEV',
icu: '58.2',
modules: '48',
openssl: '1.0.2k' }
- Node Platform (`node -p process.platform`): darwin
- Node architecture (`node -p process.arch`): x64
- node-sass version (`node -p "require('node-sass').info"`):
node-sass 4.7.2 (Wrapper) [JavaScript]
libsass 3.5.0.beta.2 (Sass Compiler) [C/C++]
- npm node-sass versions (`npm ls node-sass`): [email protected]
sivcan, wallawe, jalovatt, wenfangdu, kidar2 and 41 more