diff --git a/src/sfc/parser.js b/src/sfc/parser.js index 868a43ca082..957e5d97085 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.deindent !== false) { + 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..ecc97fc5c33 100644 --- a/test/unit/modules/sfc/sfc-parser.spec.js +++ b/test/unit/modules/sfc/sfc-parser.spec.js @@ -55,6 +55,33 @@ describe('Single File Component parser', () => { expect(res.template.content.trim()).toBe('