wip: improve v-if codegen output formatting
This commit is contained in:
parent
9c01e0bf0d
commit
3415bbd823
@ -48,7 +48,7 @@ export interface CodegenContext extends Required<CodegenOptions> {
|
|||||||
map?: SourceMapGenerator
|
map?: SourceMapGenerator
|
||||||
push(code: string, node?: CodegenNode): void
|
push(code: string, node?: CodegenNode): void
|
||||||
indent(): void
|
indent(): void
|
||||||
deindent(): void
|
deindent(withoutNewLine?: boolean): void
|
||||||
newline(): void
|
newline(): void
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +100,12 @@ function createCodegenContext(
|
|||||||
indent() {
|
indent() {
|
||||||
newline(++context.indentLevel)
|
newline(++context.indentLevel)
|
||||||
},
|
},
|
||||||
deindent() {
|
deindent(withoutNewLine = false) {
|
||||||
newline(--context.indentLevel)
|
if (withoutNewLine) {
|
||||||
|
--context.indentLevel
|
||||||
|
} else {
|
||||||
|
newline(--context.indentLevel)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
newline() {
|
newline() {
|
||||||
newline(context.indentLevel)
|
newline(context.indentLevel)
|
||||||
@ -300,7 +304,7 @@ function genIfBranch(
|
|||||||
} else {
|
} else {
|
||||||
context.push(`null`)
|
context.push(`null`)
|
||||||
}
|
}
|
||||||
deindent()
|
deindent(true /* without newline */)
|
||||||
} else {
|
} else {
|
||||||
// v-else
|
// v-else
|
||||||
__DEV__ && assert(nextIndex === branches.length)
|
__DEV__ && assert(nextIndex === branches.length)
|
||||||
|
Loading…
Reference in New Issue
Block a user