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

Should error on selector with invalid quote mark #2082

Closed
xzyfer opened this issue May 11, 2016 · 3 comments
Closed

Should error on selector with invalid quote mark #2082

xzyfer opened this issue May 11, 2016 · 3 comments

Comments

@xzyfer
Copy link
Contributor

xzyfer commented May 11, 2016

Discovered from #2080

Sass

$prefix: "";
$suffix: bar;
$class: $prefix#{"-"}#{$suffix};

#{$class} {
  foo: bar;
}

LibSass 3.3.6

""-bar {
  foo: bar;
}

Ruby Sass 3.4.21

Invalid CSS after "": expected selector, was """-bar"

Spec added sass/sass-spec#912

@xzyfer
Copy link
Contributor Author

xzyfer commented Sep 8, 2016

A work around for this is Interpolating $prefix because interpolation should always return an unquoted string.

$class: #{$prefix}#{"-"}#{$suffix};

Produces

-bar {
  foo: bar;
}

@xzyfer xzyfer modified the milestones: 3.4.1, 3.4 Sep 8, 2016
@xzyfer xzyfer modified the milestones: 3.4.1, 3.4.x Dec 28, 2016
xzyfer added a commit to sass/sass-spec that referenced this issue Jul 17, 2017
xzyfer added a commit to xzyfer/sass-spec that referenced this issue Aug 31, 2017
xzyfer added a commit to xzyfer/sass-spec that referenced this issue Aug 31, 2017
xzyfer added a commit to sass/sass-spec that referenced this issue Aug 31, 2017
@xzyfer
Copy link
Contributor Author

xzyfer commented Aug 31, 2017

@nex3 can you please confirm what the expected output of this is? I'm getting contradicting results from Ruby Sass 3.4, 3.5, and 4.

$prefix: "";
$suffix: bar;
$class: $prefix#{"-"}#{$suffix};

#{$class} {
  foo: bar;
}

@nex3
Copy link
Contributor

nex3 commented Sep 29, 2017

It depends if you're using the 3.X interpolation parsing scheme or the 4.0 scheme. Under 3.X, $prefix#{"-"}#{suffix} converts $prefix to a string (in this case, the unquoted string containing two double quote characters) and concatenates it with the string -bar. Under 4.0, the fact that the $prefix variable is next to #{"-"}#{$suffix} doesn't matter, so it's instead parsed as a list containing two values: an empty quoted string and the unquoted string -bar.

Don't forget I wrote up a whole thing about interpolation parsing in sass/sass#1778.

xzyfer added a commit to sass/sass-spec that referenced this issue Oct 2, 2017
xzyfer added a commit to sass/sass-spec that referenced this issue Oct 2, 2017
xzyfer added a commit to sass/sass-spec that referenced this issue Oct 2, 2017
xzyfer added a commit to sass/sass-spec that referenced this issue Oct 2, 2017
xzyfer added a commit to sass/sass-spec that referenced this issue Oct 2, 2017
xzyfer added a commit to sass/sass-spec that referenced this issue Oct 2, 2017
xzyfer added a commit to sass/sass-spec that referenced this issue Oct 2, 2017
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

2 participants