Skip to content

Commit 2fae757

Browse files
committed
fix(compiler): use setInsertionState instead of insert
1 parent 7fcd904 commit 2fae757

File tree

5 files changed

+7
-16
lines changed

5 files changed

+7
-16
lines changed

packages/compiler/src/transforms/transformChildren.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ function processDynamicChildren(context: TransformContext<Node>) {
8484
}
8585

8686
if (prevDynamics.length) {
87-
context.registerOperation({
88-
type: IRNodeTypes.INSERT_NODE,
89-
elements: prevDynamics.map((child) => child.id!),
90-
parent: context.reference(),
91-
})
87+
registerInsertion(prevDynamics, context)
9288
}
9389
}
9490

@@ -106,14 +102,10 @@ function registerInsertion(
106102
parent: context.reference(),
107103
anchor,
108104
})
109-
} else {
105+
} else if (child.operation && isBlockOperation(child.operation)) {
110106
// block types
111-
for (const op of context.block.operation) {
112-
if (isBlockOperation(op) && op.id === child.id) {
113-
op.parent = context.reference()
114-
op.anchor = anchor
115-
}
116-
}
107+
child.operation.parent = context.reference()
108+
child.operation.anchor = anchor
117109
}
118110
}
119111
}

packages/compiler/src/transforms/transformText.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ function processInterpolation(context: TransformContext) {
112112
const id = context.reference()
113113

114114
if (isFragmentNode(parent)) {
115-
context.dynamic.flags |= DynamicFlag.INSERT | DynamicFlag.NON_TEMPLATE
116115
context.registerOperation({
117116
type: IRNodeTypes.CREATE_NODES,
118117
id,

packages/compiler/test/transforms/__snapshots__/expression.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function render(_ctx) {
5353
exports[`compiler: expression > conditional expression with v-once 1`] = `
5454
"
5555
const n5 = t2()
56+
_setInsertionState(n5)
5657
const n0 = _createIf(() => (ok), () => {
5758
const n2 = t0()
5859
const x2 = _child(n2)
@@ -62,7 +63,6 @@ exports[`compiler: expression > conditional expression with v-once 1`] = `
6263
const n4 = t1()
6364
return n4
6465
})
65-
_insert(n0, n5)
6666
return n5
6767
"
6868
`;

packages/compiler/test/transforms/__snapshots__/vFor.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ exports[`compiler: v-for > nested v-for 1`] = `
5555
"
5656
const n0 = _createFor(() => (list), (_for_item0) => {
5757
const n5 = t1()
58+
_setInsertionState(n5)
5859
const n2 = _createFor(() => (_for_item0.value), (_for_item1) => {
5960
const n4 = t0()
6061
const x4 = _child(n4)
6162
_setNodes(x4, () => (_for_item1.value+_for_item0.value))
6263
return n4
6364
}, null, 1)
64-
_insert(n2, n5)
6565
return n5
6666
})
6767
return n0

packages/compiler/test/transforms/__snapshots__/vOnce.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ exports[`compiler: v-once > inside v-once 1`] = `
2929
exports[`compiler: v-once > on component 1`] = `
3030
"
3131
const n1 = t0()
32+
_setInsertionState(n1)
3233
const n0 = _createComponent(Comp, { id: () => (foo) }, null, null, true)
33-
_insert(n0, n1)
3434
return n1
3535
"
3636
`;

0 commit comments

Comments
 (0)