Skip to content

Commit

Permalink
fix(sfc): do not deindent space-padded output
Browse files Browse the repository at this point in the history
  • Loading branch information
ypresto committed Aug 28, 2018
1 parent 3b43c81 commit 45e70be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/sfc/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/modules/sfc/sfc-parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ describe('Single File Component parser', () => {
expect(padSpace.script.content).toBe(`<template>
<div></div>
</template>
<script>`.replace(/./g, ' ') + '\nexport default {}\n')
<script>`.replace(/./g, ' ') + '\n export default {}\n ')
expect(padSpace.styles[0].content).toBe(`<template>
<div></div>
</template>
<script>
export default {}
</script>
<style>`.replace(/./g, ' ') + '\nh1 { color: red }\n')
<style>`.replace(/./g, ' ') + '\n h1 { color: red }\n ')
})

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

0 comments on commit 45e70be

Please sign in to comment.