From: Jakub Pawlowicz Date: Fri, 7 Nov 2014 18:51:41 +0000 (+0000) Subject: Fixes stray whitespace tracking in blocks (@media, etc). X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=04aca0a9a5cc3abacd03d030ca340c014060704b;p=clean-css.git Fixes stray whitespace tracking in blocks (@media, etc). --- diff --git a/lib/selectors/tokenizer.js b/lib/selectors/tokenizer.js index d1c727cc..2a45316e 100644 --- a/lib/selectors/tokenizer.js +++ b/lib/selectors/tokenizer.js @@ -207,6 +207,8 @@ function tokenize(context) { continue; } + if (context.mode == 'block' && context.addSourceMap) + SourceMaps.track(chunk.substring(context.cursor, nextSpecial), context); if (context.mode != 'block') tokenized = chunk.substring(context.cursor, nextSpecial); diff --git a/test/selectors/tokenizer-source-maps-test.js b/test/selectors/tokenizer-source-maps-test.js index e72589d9..99d56434 100644 --- a/test/selectors/tokenizer-source-maps-test.js +++ b/test/selectors/tokenizer-source-maps-test.js @@ -279,6 +279,29 @@ vows.describe('source-maps/analyzer') } ] ], + '@media - stray whitespace at end': [ + '@media (min-width:980px){a{color:red} }p{color:red}', + [ + { + kind: 'block', + value: '@media (min-width:980px)', + metadata: { line: 1, column: 1, source: undefined }, + isFlatBlock: false, + body: [ + { + kind: 'selector', + value: [{ value: 'a', metadata: { line: 1, column: 26, source: undefined } }], + body: [{ value: 'color:red', metadata: { line: 1, column: 28, source: undefined } }] + }, + ] + }, + { + kind: 'selector', + value: [{ value: 'p', metadata: { line: 1, column: 40, source: undefined } }], + body: [{ value: 'color:red', metadata: { line: 1, column: 42, source: undefined } }] + } + ] + ], '@font-face': [ '@font-face{font-family: "Font";\nsrc: url("font.ttf");\nfont-weight: normal;font-style: normal}a{}', [