This will result in a negative column for mapped elements where the column really is 0.
While this hasn't been an issue yet, and the generated source maps will still work in Chrome and Firefox below v64, Mozilla has implemented a source map validator. And this results in a non-working source map in Firefox 64 an above.
This is a generated Source Mapping:
AAAD,aAAD;ACCA;AAAA;aAAA;AAAA;AA8BA;AAAA;oBAAA;AAAA;AAIA;AAAA,YAAA;AAAA;AAKA;AAAA;uBAAA;AAAA;AAaA;AAAA,wBAAA
The right Source Mapping should look like this:
AAAA;AAAA;aAAA;AAAA;AA8BA;AAAA;oBAAA;AAAA;AAIA;AAAA,YAAA;AAAA;AAKA;AAAA;uBAAA;AAAA;AAaA;AAAA,wBAAA
You can test the Source Map on http://murzwin.com/base64vlq.html and convert both encoded values.
The wrong mapping decoded: 0) [0,0,0,-1], [13,0,0,-1] but you shouldn't get a negative offset (-1).
Solution:
Change line 259 to
$this->currentBlock->sourceColumn > 0 ? $this->currentBlock->sourceColumn - 1 : 0, //columns from parser are off by one
https://github.com/leafo/scssphp/blob/5caf261a0c618eeb123df944597df3ca7bdf0913/src/Formatter.php#L259
In src/Formatter.php, you call
and subtract 1 from
This will result in a negative column for mapped elements where the column really is 0.
While this hasn't been an issue yet, and the generated source maps will still work in Chrome and Firefox below v64, Mozilla has implemented a source map validator. And this results in a non-working source map in Firefox 64 an above.
This is a generated Source Mapping:
AAAD,aAAD;ACCA;AAAA;aAAA;AAAA;AA8BA;AAAA;oBAAA;AAAA;AAIA;AAAA,YAAA;AAAA;AAKA;AAAA;uBAAA;AAAA;AAaA;AAAA,wBAAA
The right Source Mapping should look like this:
AAAA;AAAA;aAAA;AAAA;AA8BA;AAAA;oBAAA;AAAA;AAIA;AAAA,YAAA;AAAA;AAKA;AAAA;uBAAA;AAAA;AAaA;AAAA,wBAAA
You can test the Source Map on http://murzwin.com/base64vlq.html and convert both encoded values. The wrong mapping decoded:
0) [0,0,0,-1], [13,0,0,-1]
but you shouldn't get a negative offset (-1).Solution: Change line 259 to