diff --git a/src/sfc/parser.js b/src/sfc/parser.js index 868a43ca082..69b9f5d6df3 100644 --- a/src/sfc/parser.js +++ b/src/sfc/parser.js @@ -83,7 +83,10 @@ export function parseComponent ( function end (tag: string, start: number, end: number) { if (depth === 1 && currentBlock) { currentBlock.end = start - let text = deindent(content.slice(currentBlock.start, currentBlock.end)) + let text = content.slice(currentBlock.start, currentBlock.end) + if (options.pad !== 'space') { + text = deindent(text) + } // pad content so that linters and pre-processors can output correct // line numbers in errors and warnings if (currentBlock.type !== 'template' && options.pad) { diff --git a/test/unit/modules/sfc/sfc-parser.spec.js b/test/unit/modules/sfc/sfc-parser.spec.js index 4cf6bad574a..949843c240b 100644 --- a/test/unit/modules/sfc/sfc-parser.spec.js +++ b/test/unit/modules/sfc/sfc-parser.spec.js @@ -78,14 +78,14 @@ describe('Single File Component parser', () => { expect(padSpace.script.content).toBe(` - -