Strip BOM before parsing, fixes #2362 (#2373)

master
Lucas Azzola 2017-07-02 02:11:13 +10:00 committed by Christopher Chedeau
parent 7cf46acb9d
commit 6f9824778d
5 changed files with 31 additions and 0 deletions

View File

@ -1,5 +1,6 @@
"use strict";
const stripBom = require("strip-bom");
const comments = require("./src/comments");
const version = require("./package.json").version;
const printAstToDoc = require("./src/printer").printAstToDoc;
@ -54,6 +55,7 @@ function ensureAllCommentsPrinted(astComments) {
}
function formatWithCursor(text, opts, addAlignmentSize) {
text = stripBom(text);
addAlignmentSize = addAlignmentSize || 0;
const ast = parser.parse(text, opts);

View File

@ -51,6 +51,7 @@
"rollup-plugin-node-resolve": "2.0.0",
"rollup-plugin-replace": "1.1.1",
"shelljs": "0.7.8",
"strip-bom": "3.0.0",
"sw-toolbox": "3.6.0",
"uglify-es": "3.0.15",
"webpack": "2.6.1"

View File

@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`bom.css 1`] = `

/* Block comment */
html {
content: "#{1}";
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* Block comment */
html {
content: "#{1}";
}
`;

8
tests/css_bom/bom.css Normal file
View File

@ -0,0 +1,8 @@

/* Block comment */
html {
content: "#{1}";
}

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "postcss" });