|
@ -281,6 +281,12 @@ Vue.component('provide-function', { |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Vue.component('component-with-slot', { |
|
|
|
|
|
render (h): VNode { |
|
|
|
|
|
return h('div', this.$slots.default) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
Vue.component('component-with-scoped-slot', { |
|
|
Vue.component('component-with-scoped-slot', { |
|
|
render (h) { |
|
|
render (h) { |
|
|
interface ScopedSlotProps { |
|
|
interface ScopedSlotProps { |
|
@ -301,6 +307,12 @@ Vue.component('component-with-scoped-slot', { |
|
|
h('child', { |
|
|
h('child', { |
|
|
// Passing down all slots from parent
|
|
|
// Passing down all slots from parent
|
|
|
scopedSlots: this.$scopedSlots |
|
|
scopedSlots: this.$scopedSlots |
|
|
|
|
|
}), |
|
|
|
|
|
h('child', { |
|
|
|
|
|
// Passing down single slot from parent
|
|
|
|
|
|
scopedSlots: { |
|
|
|
|
|
default: this.$scopedSlots.default |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
]) |
|
|
]) |
|
|
}, |
|
|
}, |
|
@ -320,16 +332,22 @@ Vue.component('narrow-array-of-vnode-type', { |
|
|
render (h): VNode { |
|
|
render (h): VNode { |
|
|
const slot = this.$scopedSlots.default!({}) |
|
|
const slot = this.$scopedSlots.default!({}) |
|
|
if (typeof slot === 'string') { |
|
|
if (typeof slot === 'string') { |
|
|
|
|
|
// <template slot-scope="data">bare string</template>
|
|
|
return h('span', slot) |
|
|
return h('span', slot) |
|
|
} else if (Array.isArray(slot)) { |
|
|
} else if (Array.isArray(slot)) { |
|
|
|
|
|
// template with multiple children
|
|
|
const first = slot[0] |
|
|
const first = slot[0] |
|
|
if (!Array.isArray(first) && typeof first !== 'string') { |
|
|
if (!Array.isArray(first) && typeof first !== 'string' && first) { |
|
|
return first |
|
|
return first |
|
|
} else { |
|
|
} else { |
|
|
return h() |
|
|
return h() |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else if (slot) { |
|
|
|
|
|
// <div slot-scope="data">bare VNode</div>
|
|
|
return slot |
|
|
return slot |
|
|
|
|
|
} else { |
|
|
|
|
|
// empty template, slot === undefined
|
|
|
|
|
|
return h() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|