Skip to content

Commit

Permalink
Merge a87c15a into 01507a9
Browse files Browse the repository at this point in the history
  • Loading branch information
meixg committed Apr 14, 2022
2 parents 01507a9 + a87c15a commit b4c0974
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/compilers/anode-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class ANodeCompiler {

compile (aNode: ANode, isRootElement: boolean): Generator<Statement> {
if (TypeGuards.isATextNode(aNode)) return this.compileText(aNode)
if (TypeGuards.isAIfNode(aNode)) return this.compileIf(aNode)
if (TypeGuards.isAIfNode(aNode)) return this.compileIf(aNode, isRootElement)
if (TypeGuards.isAForNode(aNode)) return this.compileFor(aNode)
if (TypeGuards.isASlotNode(aNode)) return this.compileSlot(aNode)
if (TypeGuards.isAFragmentNode(aNode) && aNode.tagName === 'template') return this.compileTemplate(aNode)
Expand Down Expand Up @@ -112,7 +112,7 @@ export class ANodeCompiler {
yield new Else(this.compileElement(aNode, dynamicTagName, isRootElement))
}

private * compileIf (aNode: AIfNode): Generator<Statement> {
private * compileIf (aNode: AIfNode, isRootElement: boolean): Generator<Statement> {
const ifDirective = aNode.directives.if

// 动态节点 s-is 的子节点,会被编译两次。期间不能被修改。
Expand All @@ -124,11 +124,11 @@ export class ANodeCompiler {
// @ts-ignore
delete aNodeWithoutIf.directives.if

yield new If(sanExpr(ifDirective.value), this.compile(aNodeWithoutIf, false))
yield new If(sanExpr(ifDirective.value), this.compile(aNodeWithoutIf, isRootElement))

for (const elseANode of aNode.elses || []) {
const elifDirective = elseANode.directives.elif
const body = this.compile(elseANode, false)
const body = this.compile(elseANode, isRootElement)
yield elifDirective ? new ElseIf(sanExpr(elifDirective.value), body) : new Else(body)
}
}
Expand Down

0 comments on commit b4c0974

Please sign in to comment.