(vnode: VNode)
| 261 | } |
| 262 | |
| 263 | function convertLegacySlots(vnode: VNode): VNode { |
| 264 | const { props, children } = vnode |
| 265 | |
| 266 | let slots: Record<string, any> | undefined |
| 267 | |
| 268 | if (vnode.shapeFlag & ShapeFlags.COMPONENT && isArray(children)) { |
| 269 | slots = {} |
| 270 | // check "slot" property on vnodes and turn them into v3 function slots |
| 271 | for (let i = 0; i < children.length; i++) { |
| 272 | const child = children[i] |
| 273 | const slotName = |
| 274 | (isVNode(child) && child.props && child.props.slot) || 'default' |
| 275 | const slot = slots[slotName] || (slots[slotName] = [] as any[]) |
| 276 | if (isVNode(child) && child.type === 'template') { |
| 277 | slot.push(child.children) |
| 278 | } else { |
| 279 | slot.push(child) |
| 280 | } |
| 281 | } |
| 282 | if (slots) { |
| 283 | for (const key in slots) { |
| 284 | const slotChildren = slots[key] |
| 285 | slots[key] = () => slotChildren |
| 286 | slots[key]._ns = true /* non-scoped slot */ |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | const scopedSlots = props && props.scopedSlots |
| 292 | if (scopedSlots) { |
| 293 | delete props!.scopedSlots |
| 294 | if (slots) { |
| 295 | extend(slots, scopedSlots) |
| 296 | } else { |
| 297 | slots = scopedSlots |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | if (slots) { |
| 302 | normalizeChildren(vnode, slots) |
| 303 | } |
| 304 | |
| 305 | return vnode |
| 306 | } |
| 307 | |
| 308 | export function defineLegacyVNodeProperties(vnode: VNode): void { |
| 309 | /* v8 ignore start */ |
no test coverage detected