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

Unexpected \a between selectors #1328

Closed
dennisfrank opened this issue Jul 8, 2015 · 10 comments
Closed

Unexpected \a between selectors #1328

dennisfrank opened this issue Jul 8, 2015 · 10 comments

Comments

@dennisfrank
Copy link

I stumbled over following issue:

http://sassmeister.com/gist/51e6f8724f98f49ffcf4

@mixin foo($foo: bar) {
  .#{$foo}:before,
  [data-attribute="#{$foo}"]:before,
  [data-another-attribute="#{$foo}"]:before {
    content: "whatever";
  }
}

@include foo;

will become

.bar:before,
[data-attribute="bar"]:before, \a [data-another-attribute="bar"]:before {
    content: "whatever";
}

instead of

.bar:before,
[data-attribute="bar"]:before,
[data-another-attribute="bar"]:before {
    content: "whatever";
}

The line-break between the second and third selector gets replaced by \a and breaks the CSS.

If you remove .#{$foo}:before, or append a space or another character to the data-attribute value like [data-attribute="#{$foo} "]:before, the \a disappears but the CSS is wrong.

As a crude workaround you can replace the double quotes of one(!) selector with single quotes:

@mixin foo($foo: bar) {
  .#{$foo}:before,
  [data-attribute='#{$foo}']:before,
  [data-another-attribute="#{$foo}"]:before {
    content: "whatever";
  }
}

@include foo;

will become

.bar:before,
[data-attribute='bar']:before,
[data-another-attribute="bar"]:before {
    content: "whatever";
}

When both selectors contain the same quotes (double or single) it breaks again.

@mgreter
Copy link
Contributor

mgreter commented Jul 8, 2015

This seems already fixed with my latest refactoring branch (//CC @xzyfer)

@dennisfrank
Copy link
Author

@mgreter @xzyfer If this is already fixed, that would be great!

BTW same issue with @each:

@each $item, $value in $items {
    .#{$foo}:before,
    [data-attribute="#{$foo}"]:before,
    [data-another-attribute="#{$foo}"]:before {
        content: "whatever";
  }
}

@xzyfer
Copy link
Contributor

xzyfer commented Jul 9, 2015

I've seen a couple reports of this. It'd be good to have a failing test case to ensure this doesn't regress. I'll work it.

@xzyfer xzyfer added this to the 3.3 milestone Jul 9, 2015
xzyfer added a commit to xzyfer/sass-spec that referenced this issue Jul 13, 2015
@xzyfer
Copy link
Contributor

xzyfer commented Jul 13, 2015

Spec added sass/sass-spec#446

@mgreter
Copy link
Contributor

mgreter commented Jul 14, 2015

it seems that the fix for this is somewhere burried in one of my refactorings ...

@xzyfer xzyfer closed this as completed Jul 14, 2015
@mgreter mgreter reopened this Jul 14, 2015
@mgreter
Copy link
Contributor

mgreter commented Jul 14, 2015

IMO this is not fixed yet, waiting for that fix to come up ...

@mgreter
Copy link
Contributor

mgreter commented Jul 15, 2015

It seems this problem only happens if you use windows linefeeds ...

@dennisfrank
Copy link
Author

Hm. This file has LF unix line endings: http://cl.ly/code/2Y21191G2S3p/download/test.app.scss

Same problem.

@mgreter
Copy link
Contributor

mgreter commented Jul 15, 2015

The whole thing was a lot weirder and has indeed to do with how we parse css strings (@xzyfer this is actually where the differences between static and quoted strings come into play). Anyway, I think I have a proper fix in #1349!

mgreter added a commit to mgreter/libsass that referenced this issue Jul 15, 2015
mgreter added a commit to mgreter/libsass that referenced this issue Jul 15, 2015
mgreter added a commit to mgreter/libsass that referenced this issue Jul 15, 2015
mgreter added a commit to mgreter/libsass that referenced this issue Jul 15, 2015
mgreter added a commit to mgreter/libsass that referenced this issue Jul 16, 2015
@xzyfer
Copy link
Contributor

xzyfer commented Jul 16, 2015

For what it's worth I was able to reproduce this 100% on OSX

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

3 participants