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

SourceMaps lines offset for interpolated selectors #2224

Closed
rodneyrehm opened this issue Nov 3, 2016 · 5 comments
Closed

SourceMaps lines offset for interpolated selectors #2224

rodneyrehm opened this issue Nov 3, 2016 · 5 comments

Comments

@rodneyrehm
Copy link
Contributor

rodneyrehm commented Nov 3, 2016

The SourceMaps generation seems to trip over multi-line selectors if they contain interpolations (#{$variable}). In the demo SCSS below the generated CSS .zulu-delta is referenced to line 17, while it should be line 19. This does not happen for non-interpolated multi-line selectors. A single interpolation in the selector string causes the lines to collapse before the mutation could be tracked in SourceMaps. The offset is not recovered from, so all SCSS content after such an interpolated selector is affected by the shift in line number.

input.scss (SourceMap)

$prefix: zulu;

.alpha,
.bravo,
.charlie {
  color: red;
}

.delta {
  color: blue;
}

.#{$prefix}-alpha,
.#{$prefix}-bravo,
.#{$prefix}-charlie {
  color: red;
}

.#{$prefix}-delta {
  color: blue;
}

.echo {
  color: green;
}

version info:

$ node-sass --version
node-sass	3.11.0	(Wrapper)	[JavaScript]
libsass  	3.3.6	(Sass Compiler)	[C/C++]
@mgreter
Copy link
Contributor

mgreter commented Nov 3, 2016

Thanks for the thorough bug report. I can see the issue clearly in the sourcemap inspector. I suspect the error to stem from reparsing the interpolated selectors on the eval stage (unconfirmed).

@mgreter
Copy link
Contributor

mgreter commented Nov 3, 2016

@rodneyrehm can you tell on which versions you saw this error. Wondering if it got introduced with some latest sourcemap changes in 3.4-RC1. I specially would like to know if 3.3.6 already had this issue!? Thx!

@rodneyrehm
Copy link
Contributor Author

can you tell on which versions you saw this error.

@mgreter the OP includes the node-sass --version output - this happened in libsass 3.3.6. I've also confirmed this issue still exists in libsass 3.4.0-RC1 via compiling it to sass.js.

@mgreter
Copy link
Contributor

mgreter commented Dec 29, 2016

I have updated my sourcemap inspector to PR #2268. @nschonni can you check it to see if #2268 fixes the most urgent issue. As laid out in said PR, the mappings for the selector schema parts are still garbage, but at least to following mappings should no longer be off!

@mgreter mgreter self-assigned this Dec 29, 2016
@mgreter
Copy link
Contributor

mgreter commented Jan 5, 2017

I have merged #2268. It should fix the most urgent problems here!

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