Skip to content

Commit

Permalink
fix: ChildComponetClass 可能会重复
Browse files Browse the repository at this point in the history
  • Loading branch information
meixg committed Dec 3, 2021
1 parent 158bdd3 commit d8e0fa0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/compilers/anode-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as TypeGuards from '../ast/san-ast-type-guards'
import { IDGenerator } from '../utils/id-generator'
import { JSONStringify, RegexpReplace, Statement, SlotRendererDefinition, ElseIf, Else, MapAssign, Foreach, If, MapLiteral, ComponentRendererReference, FunctionCall, SlotRenderCall, Expression, GetRootCtxCall, ComponentReferenceLiteral, ComponentClassReference } from '../ast/renderer-ast-dfn'
import { CTX_DATA, createHTMLExpressionAppend, createHTMLLiteralAppend, L, I, ASSIGN, STATEMENT, UNARY, DEF, BINARY, RETURN } from '../ast/renderer-ast-util'
import { sanExpr, OutputType } from '../compilers/san-expr-compiler'
import { sanExpr, OutputType } from './san-expr-compiler'
import type { RenderOptions } from './renderer-options'

/**
Expand Down Expand Up @@ -225,15 +225,18 @@ export class ANodeCompiler<T extends 'none' | 'typed'> {
const ndo = isRootElement ? I('noDataOutput') : L(true)

// child component class
let ChildComponentClassName = ''
if (this.useProvidedComponentClass) {
yield DEF('ChildComponentClass', new ComponentClassReference(ref, L(aNode.tagName)))
ChildComponentClassName = this.id.next('ChildComponentClass')
yield DEF(ChildComponentClassName, new ComponentClassReference(ref, L(aNode.tagName)))
}

// get and call renderer
const args = [this.childRenderData(aNode), ndo, I('parentCtx'), L(aNode.tagName), childSlots]
if (this.useProvidedComponentClass) {
assert(ChildComponentClassName !== '')
args.push(new MapLiteral([
[I('ComponentClass'), I('ChildComponentClass')]
[I('ComponentClass'), I(ChildComponentClassName)]
]))
}
const childRenderCall = new FunctionCall(
Expand Down

0 comments on commit d8e0fa0

Please sign in to comment.