diff --git a/lib/safe-parser.js b/lib/safe-parser.js index 4a26c24..e30519b 100644 --- a/lib/safe-parser.js +++ b/lib/safe-parser.js @@ -38,6 +38,9 @@ class SafeParser extends Parser { decl(tokens) { if (tokens.length > 1 && tokens.some(i => i[0] === 'word')) { super.decl(tokens) + // Words before colon are already in raws.between, + // so remove their copy added by unknownWord() + this.spaces = '' } } diff --git a/test/parse.test.js b/test/parse.test.js index 6e0acbb..d5fe65f 100644 --- a/test/parse.test.js +++ b/test/parse.test.js @@ -78,6 +78,7 @@ test('fixes 2 properties in safe mode', () => { equal(root.first.nodes.length, 1) equal(root.first.first.prop, 'color') equal(root.first.first.raws.between, ' one: ') + equal(root.toString(), 'a { color one: white; one }') }) test('fixes nameless at-rule in safe mode', () => {