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
support colliding CSS filter effects functions #515
Conversation
Adding test for sass/libsass#151 and pull request sass/libsass#515
I didn't see any tests for this, so @malrase wrote some up. It is here: https://github.com/malrase/sass-spec/blob/issue_151/spec/libsass-todo-issues/issue_151/input.scss WE ARE SO CLOSE... but the tests that we wrote fail. With Sass 3.4, when you do "saturate(red)" with only one variable, it doesn't error, it returns "saturate(red)". Right now, as written, it breaks. So close! Come on! Help us finish this one up! |
Here's the saturate test case as a gist: If Sass sees one variable, it just ignores the saturate() and exports it directly into the CSS. If there's two variables, it does the colour maths on saturate(). |
I added a new test to the sass-spec (PR: sass/sass-spec#66) to cover the weird saturate() case. |
Ah, okay. I added some tests of my own for this way back when (sass/sass-spec#35), but looks like I missed the tricky saturate case. I'm on it! |
CSS filter effects [0] define several functions (invert, grayscale, opacity, saturation) that collide with the names of built-in Sass functions. Overload these functions with a no-op when the filter effects function signature is discovered. This is compatible with Ruby Sass. For example, calling `invert` with a color will return an inverted color as before: color: invert(sass#333) => color: #cccccc But calling `invert` with a percentage will pass through the function call unharmed. filter: invert(30%) => filter: invert(30%) filter: invert(.03) => filter: invert(.03) Fixes sass#151. [0]: http://www.w3.org/TR/filter-effects/
For consistency with Sass.
Since RGB channels are stored as doubles, HSL/RGB conversions can result in decimal values being stored for a channel. This breaks color name lookup. For example, previously rgb(127.5, 127.5, 127.5) would fail to be converted to "gray," despite being rounded and output as #808080 which *does* map to gray. So instead of performing the rounding only when outputting as a hex triplet, perform the rounding at the start, always. This achieves consistency with Sass.
8a866f3
to
46769e9
Compare
Well, that was tricky. Turns out the
was getting rejected as a CSS3 filter function overload, since
would get accepted as a CSS3 filter function overload, since Anyway, for compliance with Sass, I've updated the overload to naively check for the existence of the second Then just a couple minor output formatting modifications (see commit messages) to achieve parity with Sass. |
Alright, this looks good to me now. |
support colliding CSS filter effects functions
@hcatlin this a rebased #467.
I wasn't able to repro your
alpha
test failures—isalpha
even tested?—but this passes./script/spec
successfully for me!CSS filter effects 0 define several functions (invert, grayscale,
opacity, saturation) that collide with the names of built-in Sass
functions. Overload these functions with a no-op when the filter effects
function signature is discovered. This is compatible with Ruby Sass.
For example, calling
invert
with a color will return an inverted coloras before:
But calling
invert
with a percentage will pass through the functioncall unharmed.
Fixes #151.