Skip to content

Commit 45e70be

Browse files
committed
fix(sfc): do not deindent space-padded output
1 parent 3b43c81 commit 45e70be

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Diff for: src/sfc/parser.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ export function parseComponent (
8383
function end (tag: string, start: number, end: number) {
8484
if (depth === 1 && currentBlock) {
8585
currentBlock.end = start
86-
let text = deindent(content.slice(currentBlock.start, currentBlock.end))
86+
let text = content.slice(currentBlock.start, currentBlock.end)
87+
if (options.pad !== 'space') {
88+
text = deindent(text)
89+
}
8790
// pad content so that linters and pre-processors can output correct
8891
// line numbers in errors and warnings
8992
if (currentBlock.type !== 'template' && options.pad) {

Diff for: test/unit/modules/sfc/sfc-parser.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ describe('Single File Component parser', () => {
7878
expect(padSpace.script.content).toBe(`<template>
7979
<div></div>
8080
</template>
81-
<script>`.replace(/./g, ' ') + '\nexport default {}\n')
81+
<script>`.replace(/./g, ' ') + '\n export default {}\n ')
8282
expect(padSpace.styles[0].content).toBe(`<template>
8383
<div></div>
8484
</template>
8585
<script>
8686
export default {}
8787
</script>
88-
<style>`.replace(/./g, ' ') + '\nh1 { color: red }\n')
88+
<style>`.replace(/./g, ' ') + '\n h1 { color: red }\n ')
8989
})
9090

9191
it('should handle template blocks with lang as special text', () => {

0 commit comments

Comments
 (0)