Skip to content

Commit 1c5cf09

Browse files
committed
fix(compiler): use createNodes instead of setNodes for v-slot
1 parent 121fcc8 commit 1c5cf09

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

packages/compiler/src/transforms/transformText.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type RootNode,
66
} from '../ir'
77
import {
8+
findProp,
89
getLiteralExpressionValue,
910
isEmptyText,
1011
isJSXComponent,
@@ -111,7 +112,7 @@ function processInterpolation(context: TransformContext) {
111112

112113
const id = context.reference()
113114

114-
if (isFragmentNode(parent)) {
115+
if (isFragmentNode(parent) || findProp(parent, 'v-slot')) {
115116
context.registerOperation({
116117
type: IRNodeTypes.CREATE_NODES,
117118
id,

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ exports[`compiler: transform slot > nested slots scoping 1`] = `
126126
"default": (_slotProps0) => {
127127
const n5 = _createComponent(Inner, null, {
128128
"default": (_slotProps1) => {
129-
const n3 = t0()
130-
_setNodes(n3, () => (_slotProps0["foo"] + _slotProps1["bar"] + baz))
129+
const n3 = _createNodes(() => (_slotProps0["foo"] + _slotProps1["bar"] + baz))
131130
return n3
132131
}
133132
})
@@ -146,8 +145,7 @@ exports[`compiler: transform slot > on component dynamically named slot 1`] = `
146145
() => ({
147146
name: named,
148147
fn: (_slotProps0) => {
149-
const n0 = t0()
150-
_setNodes(n0, () => (_slotProps0["foo"] + bar))
148+
const n0 = _createNodes(() => (_slotProps0["foo"] + bar))
151149
return n0
152150
}
153151
})
@@ -161,8 +159,7 @@ exports[`compiler: transform slot > on component named slot 1`] = `
161159
"
162160
const n1 = _createComponent(Comp, null, {
163161
"named": (_slotProps0) => {
164-
const n0 = t0()
165-
_setNodes(n0, () => (_slotProps0["foo"] + bar))
162+
const n0 = _createNodes(() => (_slotProps0["foo"] + bar))
166163
return n0
167164
}
168165
})
@@ -174,8 +171,7 @@ exports[`compiler: transform slot > on-component default slot 1`] = `
174171
"
175172
const n1 = _createComponent(Comp, null, {
176173
"default": (_slotProps0) => {
177-
const n0 = t0()
178-
_setNodes(n0, () => (_slotProps0["foo"] + bar))
174+
const n0 = _createNodes(() => (_slotProps0["foo"] + bar))
179175
return n0
180176
}
181177
})

0 commit comments

Comments
 (0)