-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Variables in background shorthand produce an error #1560
Comments
This is mentioned in the docs:
$clock-size: 4.2rem;
.clock {
background: url(/includes/image/clocks.svg) no-repeat 0 0 / #{$clock-size * 13} $clock-size;
} |
Consider this a feature request then ;) It looks like SASS should be able to figure this out without me having to tell it explicitly to keep its hands off, so to speak. Also, the fact that it spews out syntactically incorrect CSS should be an indication for itself this it has misinterpreted something. |
Not sure that I agree that "Sass should know". Consider the following: $font-size: 100%;
$multiplier: 15px;
.foo {
font: $font-size / $multiplier sans-serif;
} How is Sass supposed to know that you mean here? To output Sass doesn't know what's "valid" for any given property, it only knows what patterns are valid. This allows it to be future proof. You don't need to upgrade Sass just because a new property was added to the spec or made up by the browser vendors (hell, I make up new ones when I am doing debugging on Sassmeister). |
Allow me to disagree. |
@hugogiraudel, here's a counter-argument: Sass aims not to derive from CSS standard, and CSS does use |
Here's another counter-argument: using But anyhow, SASS is outputting syntactically incorrect css in my example. That's a whole different story from invalid css for a given propery. |
@thany which is it now? Sass is throwing an error because you're doing something invalid (division with incompatible units) or Sass is generating invalid CSS? It can't be doing both. |
It's throwing an error were none is neccesary. And it's trying to generate syntactically invalid css. I'm saying that if it turns out an expression like in my example produces css, maybe SASS should try handling the |
SCSS is a CSS superset. This means that Sass will treat the .clock {
background: url(/includes/image/clocks.svg) no-repeat 0 0 / 70 15;
} Now, the question is, what should Sass do if you're using SassScript in this context. And here we have decided that once you start using SassScript the benefit of letting |
What Sass should do is not try to generate invalid css. If the Sass is syntactically valid, it should never spew out syntactically incorrect css no matter what. Invalid css is one thing, byt syntactically invalid css shouldn't happen in this case. |
What do you consider to be "semantically valid Sass"? Is it what you expect it to be? From my point of view, "syntactically valid Sass" is what @nex3 and @chriseppstein determine to be. |
Syntactically valid is what the compiler can parse and work with. But that on its turn, is trying to produce syntactically invalid css, as per the error message. Sure, |
One could say:
And many folks already consider it "good practice" to enclose all inline calculation in braces, so such a change wouldn't change much for the worse. |
@thany Sass isn't generating invalid CSS, it is raising an error telling you that you f'ed up. How the division operator behaves is well documented. http://sass-lang.com/documentation/file.SASS_REFERENCE.html#division-and-slash |
Well documented or not, it's still confusing. I didn't raise this issue because it's crystal clear, did I? Plus, it doesn't change how |
So will this be fixed at some point or not? I'm running into this again, by writing down something that is completely sensible:
It says:
I know this, and apparently Sass knows this as well. So why is it trying to ouput something it knows is going to be invalid if it did?? A silly workaround:
|
The issue is closed, indicating that the behavior won't be changed from how it currently works. |
I realize that, so I'm asking for reconsideration. Because, well, like I said, Sass trying to produce "1.234%/rem" as a value, and erroring on it, isn't useful. |
This works:
This doesn't:
It'll produce this error:
Which is a weird error to begin with. Why would sass output css that can never be valid for anything, especially if the scss is perfectly valid?...
As you can see, the current workaround is to use the longhand for
background-size
, but I'd prefer to be able to realiably use the shorthand as well.I'm using SASS 3.4.9, Gem 2.4.5, Ruby 2.1.3p242 x64, and Windows 7 x64.
The text was updated successfully, but these errors were encountered: