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

:nth-of-type(2n - 1) space in argument results in error #1650

Closed
kkopachev opened this issue Oct 27, 2015 · 6 comments
Closed

:nth-of-type(2n - 1) space in argument results in error #1650

kkopachev opened this issue Oct 27, 2015 · 6 comments

Comments

@kkopachev
Copy link

Updated to new libsass/node-sass recently and noticed regression (or intended?) with the code:

tr:nth-of-type(2n - 1) { color: red; }

outputs an error

"Invalid CSS after "": expected 1 selector or at-rule, was "th-of-type(4n -...""

While code with no spaces works:

tr:nth-of-type(2n-1) { color: red; } // works!
tr:nth-of-type(2n + 1) { color: red; } // works too!
tr:nth-of-type(2n+1) { color: red; } // and this one is fine

spacing around minus sign makes libsass complain.

$ node-sass -v
node-sass 3.4.1 (Wrapper) [JavaScript]
libsass 3.3.1 (Sass Compiler) [C/C++]

@mgreter mgreter added this to the 3.3.2 milestone Oct 27, 2015
@mgreter mgreter self-assigned this Oct 27, 2015
mgreter added a commit to mgreter/libsass that referenced this issue Oct 27, 2015
@mgreter
Copy link
Contributor

mgreter commented Oct 27, 2015

OK, this is pretty odd.

:nth-of-type(2n-1),
:nth-of-type(2n-  1),
:nth-of-type(2n  -1),
:nth-of-type(2n  -  1),
:nth-of-type( 2n  -  1 )
{ color: red; }
:nth-of-type(2n+1),
:nth-of-type(2n+  1),
:nth-of-type(2n  +1),
:nth-of-type(2n  +  1),
:nth-of-type( 2n  +  1 )
{ color: red; }

In compressed mode this produces:

:nth-of-type(2n-1),
:nth-of-type(2n-  1),
:nth-of-type(2n  -1),
:nth-of-type(2n  -  1),
:nth-of-type(2n  -  1)
{color:red}

:nth-of-type(2n+1),
:nth-of-type(2n+1),
:nth-of-type(2n+1),
:nth-of-type(2n+1),
:nth-of-type(2n+1)
{color:red}  

My current fix which gets it parsed correctly outputs:

:nth-of-type(2n-1),
:nth-of-type(2n-1),
:nth-of-type(2n-1),
:nth-of-type(2n-1),
:nth-of-type(2n-1)
{color:red}

:nth-of-type(2n+1),
:nth-of-type(2n+1),
:nth-of-type(2n+1),
:nth-of-type(2n+1),
:nth-of-type(2n+1)
{color:red}  

No idea why ruby sass does not apply the same logic here. Looks like a bug to me ...

@xzyfer
Copy link
Contributor

xzyfer commented Oct 28, 2015

The white space being preserved looks like the work of a static value parser.

@xzyfer
Copy link
Contributor

xzyfer commented Oct 28, 2015

Looks like Ruby Sass' almost_any_value_token method is the cause.

@chriseppstein
Copy link
Contributor

That's a ruby bug, not a high priority one, but definitely a bug.

@mgreter
Copy link
Contributor

mgreter commented Oct 28, 2015

@chriseppstein thanks for the confirmation, I guess it's a one byte fix on the ruby side ...

@xzyfer xzyfer modified the milestones: 3.3.2, 3.3.3 Nov 4, 2015
mgreter added a commit to mgreter/libsass that referenced this issue Nov 7, 2015
mgreter added a commit to mgreter/sass-spec that referenced this issue Jan 9, 2016
@mgreter
Copy link
Contributor

mgreter commented Jan 13, 2016

This should be fixed on master for release 3.3.3.

@mgreter mgreter closed this as completed Jan 13, 2016
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