Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use !important for css vars #2590

Closed
bhollis opened this issue Mar 16, 2018 · 6 comments
Closed

Can't use !important for css vars #2590

bhollis opened this issue Mar 16, 2018 · 6 comments

Comments

@bhollis
Copy link

bhollis commented Mar 16, 2018

input.scss

body {
    --foo: 999 !important;
}

Actual results

libsass 3.5.0 via node-sass 4.8.1

Invalid CSS after "999": expected "}", was "!important;"

Expected result

body {
    --foo: 999 !important;
}

(This worked fine in node-sass 4.7.2 / libsass 3.5.0.beta.2)

version info:

$ node-sass --version
node-sass	4.8.1	(Wrapper)	[JavaScript]
libsass  	3.5.0	(Sass Compiler)	[C/C++]
bhollis added a commit to DestinyItemManager/DIM that referenced this issue Mar 16, 2018
@asottile
Copy link
Member

Bisects to efd97da

@mgreter
Copy link
Contributor

mgreter commented Mar 17, 2018

AFAICT ruby sass 3.5 (and latest dart-sass) gives the same error!

http://sass-lang.com/documentation/file.SASS_CHANGELOG.html#3_5_0__12_July_2017_

The way CSS variables are handled has changed to better correspond to the CSS spec. They no longer allow arbitrary SassScript in their values; instead, almost all text in the property values will be passed through unchanged to CSS. The only exception is #{}, which will inject a SassScript value as before.

@xzyfer
Copy link
Contributor

xzyfer commented Mar 17, 2018

According to the spec, this is allowed

Note: Custom properties can contain a trailing !important, but this is automatically removed from the property’s value by the CSS parser, and makes the custom property "important" in the CSS cascade. In other words, the prohibition on top-level "!" characters does not prevent !important from being used, as the !important is removed before syntax checking happens.

This is a bug in all the Sass implementations.

@xzyfer
Copy link
Contributor

xzyfer commented Mar 17, 2018

I filed an issue with the reference implementation sass/dart-sass#260

@xzyfer
Copy link
Contributor

xzyfer commented Mar 23, 2018

This has been fixed in ruby sass and dart sass

@xzyfer
Copy link
Contributor

xzyfer commented Mar 23, 2018

Spec added sass/sass-spec#1236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants