Workaround a bug where the comment location is off for scss (#1799)

Workarounds https://github.com/postcss/postcss-scss/issues/63
master
Christopher Chedeau 2017-05-29 08:39:41 -07:00 committed by GitHub
parent 6cecb83cdf
commit 6a9e053221
3 changed files with 53 additions and 3 deletions

View File

@ -2533,9 +2533,19 @@ function genericPrintNoParens(path, options, print, args) {
return concat([printNodeSequence(path, options, print), hardline]);
}
case "css-comment": {
return n.raws.content
? n.raws.content
: options.originalText.slice(util.locStart(n), util.locEnd(n));
if (n.raws.content) {
return n.raws.content;
}
const text = options.originalText.slice(util.locStart(n), util.locEnd(n));
// Workaround a bug where the location is off.
// https://github.com/postcss/postcss-scss/issues/63
if (text.indexOf(n.text) === -1) {
if (n.raws.inline) {
return concat(['// ', n.text]);
}
return concat(['/* ', n.text, ' */']);
}
return text;
}
case "css-rule": {
return concat([

View File

@ -17,6 +17,34 @@ exports[`block.css 1`] = `
`;
exports[`bug.css 1`] = `
@font-face {
src: url(if(
$bootstrap-sass-asset-helper,
twbs-font-path('#{$icon-font-path}#{$icon-font-name}.eot'),
'#{$icon-font-path}#{$icon-font-name}.eot'
));
}
// Catchall baseclass
/* Catchall baseclass */
.glyphicon {
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@font-face {
src: url(if(
$bootstrap-sass-asset-helper,
twbs-font-path('#{$icon-font-path}#{$icon-font-name}.eot'),
'#{$icon-font-path}#{$icon-font-name}.eot'
));
}
// Catchall baseclass
/* Catchall baseclass */
.glyphicon {
}
`;
exports[`places.css 1`] = `
div {
// a

View File

@ -0,0 +1,12 @@
@font-face {
src: url(if(
$bootstrap-sass-asset-helper,
twbs-font-path('#{$icon-font-path}#{$icon-font-name}.eot'),
'#{$icon-font-path}#{$icon-font-name}.eot'
));
}
// Catchall baseclass
/* Catchall baseclass */
.glyphicon {
}