return h('div', this.$slots.default())
})
}
+ const withChil2Id = withScopeId('child2')
+ const Child2 = {
+ __scopeId: 'child2',
+ render: withChil2Id(() => h('span'))
+ }
const App = {
__scopeId: 'parent',
render: withParentId(() => {
return h(
Child,
withParentId(() => {
- return h('div')
+ return [h('div'), h(Child2)]
})
)
})
// - scopeId from parent
// - slotted scopeId (with `-s` postfix) from child (the tree owner)
expect(serializeInner(root)).toBe(
- `<div parent child><div parent child-s></div></div>`
+ `<div parent child>` +
+ `<div parent child-s></div>` +
+ // component inside slot should have:
+ // - scopeId from template context
+ // - slotted scopeId from slot owner
+ // - its own scopeId
+ `<span parent child-s child2></span>` +
+ `</div>`
)
})
})
): VNode {
const {
type: Component,
+ parent,
vnode,
proxy,
withProxy,
}
// inherit scopeId
- if (vnode.scopeId) {
- root = cloneVNode(root, { [vnode.scopeId]: '' })
+ const scopeId = vnode.scopeId
+ if (scopeId) {
+ root = cloneVNode(root, { [scopeId]: '' })
}
+ const treeOwnerId = parent && parent.type.__scopeId
+ if (treeOwnerId && treeOwnerId !== scopeId) {
+ root = cloneVNode(root, { [treeOwnerId + '-s']: '' })
+ }
+
// inherit directives
if (vnode.dirs) {
if (__DEV__ && !isElementRoot(root)) {