|
|
@@ -33,7 +33,6 @@ import {
|
|
|
type IRProps,
|
|
|
type IRPropsDynamicAttribute,
|
|
|
type IRPropsStatic,
|
|
|
- type OperationNode,
|
|
|
type VaporDirectiveNode,
|
|
|
} from '../ir'
|
|
|
import { EMPTY_EXPRESSION } from './utils'
|
|
|
@@ -125,26 +124,28 @@ function transformComponentElement(
|
|
|
}
|
|
|
|
|
|
context.dynamic.flags |= DynamicFlag.NON_TEMPLATE | DynamicFlag.INSERT
|
|
|
- const op: OperationNode = {
|
|
|
- type: IRNodeTypes.CREATE_COMPONENT_NODE,
|
|
|
- id: context.reference(),
|
|
|
- tag,
|
|
|
- props: propsResult[0] ? propsResult[1] : [propsResult[1]],
|
|
|
- asset,
|
|
|
- root: singleRoot,
|
|
|
- slots: [...context.slots],
|
|
|
- once: context.inVOnce,
|
|
|
- dynamic: dynamicComponent,
|
|
|
- }
|
|
|
- const hasVShow = findDir(node, 'show')
|
|
|
- if (hasVShow) {
|
|
|
- const showOperationIndex = context.block.operation.findIndex(
|
|
|
+
|
|
|
+ // ensure v-show is handled after the component is created
|
|
|
+ let showOperationIndex
|
|
|
+ if (findDir(node, 'show')) {
|
|
|
+ showOperationIndex = context.block.operation.findIndex(
|
|
|
op => op.type === IRNodeTypes.DIRECTIVE && op.name === 'show',
|
|
|
)
|
|
|
- context.registerOperationAt(op, showOperationIndex)
|
|
|
- } else {
|
|
|
- context.registerOperation(op)
|
|
|
}
|
|
|
+ context.registerOperation(
|
|
|
+ {
|
|
|
+ type: IRNodeTypes.CREATE_COMPONENT_NODE,
|
|
|
+ id: context.reference(),
|
|
|
+ tag,
|
|
|
+ props: propsResult[0] ? propsResult[1] : [propsResult[1]],
|
|
|
+ asset,
|
|
|
+ root: singleRoot,
|
|
|
+ slots: [...context.slots],
|
|
|
+ once: context.inVOnce,
|
|
|
+ dynamic: dynamicComponent,
|
|
|
+ },
|
|
|
+ showOperationIndex,
|
|
|
+ )
|
|
|
context.slots = []
|
|
|
}
|
|
|
|