@@ -128,13 +128,18 @@ export function processSkip(
128
128
processAsSkipNode = true
129
129
children = node . children
130
130
} else if ( isComponent ) {
131
- ; ( { processAsSkipNode, children } = resolveDefaultSlot (
132
- node ,
133
- context ,
134
- processAsSkipNode ,
135
- children ,
136
- loc ,
137
- ) )
131
+ const { hasDynamicSlots, defaultSlot } = resolveDefaultSlot ( node , context )
132
+ if ( ! hasDynamicSlots ) {
133
+ if ( defaultSlot ) {
134
+ processAsSkipNode = true
135
+ // using the cloned node for ssr VNode-based slot
136
+ children = context . inSSR ? clone ( defaultSlot ) : defaultSlot
137
+ } else {
138
+ context . onError (
139
+ createCompilerError ( ErrorCodes . X_V_SKIP_UNEXPECTED_SLOT , loc ) ,
140
+ )
141
+ }
142
+ }
138
143
}
139
144
140
145
let skipNode : SkipNode | undefined
@@ -155,6 +160,7 @@ export function processSkip(
155
160
consequent,
156
161
alternate : createBranchNode ( node , node . loc , [ node ] ) ,
157
162
newline : true ,
163
+ codegenNode : undefined ,
158
164
}
159
165
160
166
context . replaceNode ( skipNode )
@@ -163,17 +169,11 @@ export function processSkip(
163
169
if ( processCodegen ) return processCodegen ( skipNode )
164
170
}
165
171
166
- function resolveDefaultSlot (
167
- node : ComponentNode ,
168
- context : TransformContext ,
169
- processAsSkipNode : boolean ,
170
- children : TemplateChildNode [ ] ,
171
- loc : SourceLocation ,
172
- ) {
172
+ function resolveDefaultSlot ( node : ComponentNode , context : TransformContext ) {
173
+ let defaultSlot : TemplateChildNode [ ] | undefined = undefined
173
174
const { slots, hasDynamicSlots } = buildSlots ( node , context , undefined , true )
174
175
// find default slot without slot props if not has dynamic slots
175
176
if ( ! hasDynamicSlots && slots . type === NodeTypes . JS_OBJECT_EXPRESSION ) {
176
- processAsSkipNode = true
177
177
const prop = slots . properties . find (
178
178
p =>
179
179
p . type === NodeTypes . JS_PROPERTY &&
@@ -182,17 +182,10 @@ function resolveDefaultSlot(
182
182
p . value . params === undefined ,
183
183
)
184
184
if ( prop ) {
185
- const slotNode = prop . value . returns as TemplateChildNode [ ]
186
- // using the cloned node for ssr VNode-based slot
187
- children = context . inSSR ? clone ( slotNode ) : slotNode
188
- } else {
189
- context . onError (
190
- createCompilerError ( ErrorCodes . X_V_SKIP_UNEXPECTED_SLOT , loc ) ,
191
- )
185
+ defaultSlot = prop . value . returns as TemplateChildNode [ ]
192
186
}
193
187
}
194
-
195
- return { processAsSkipNode, children }
188
+ return { hasDynamicSlots, defaultSlot }
196
189
}
197
190
198
191
function createBranchNode (
0 commit comments