File tree 2 files changed +23
-4
lines changed
2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -45,13 +45,18 @@ describe('scopeId runtime support', () => {
45
45
return h ( 'div' , this . $slots . default ( ) )
46
46
} )
47
47
}
48
+ const withChil2Id = withScopeId ( 'child2' )
49
+ const Child2 = {
50
+ __scopeId : 'child2' ,
51
+ render : withChil2Id ( ( ) => h ( 'span' ) )
52
+ }
48
53
const App = {
49
54
__scopeId : 'parent' ,
50
55
render : withParentId ( ( ) => {
51
56
return h (
52
57
Child ,
53
58
withParentId ( ( ) => {
54
- return h ( 'div' )
59
+ return [ h ( 'div' ) , h ( Child2 ) ]
55
60
} )
56
61
)
57
62
} )
@@ -62,7 +67,14 @@ describe('scopeId runtime support', () => {
62
67
// - scopeId from parent
63
68
// - slotted scopeId (with `-s` postfix) from child (the tree owner)
64
69
expect ( serializeInner ( root ) ) . toBe (
65
- `<div parent child><div parent child-s></div></div>`
70
+ `<div parent child>` +
71
+ `<div parent child-s></div>` +
72
+ // component inside slot should have:
73
+ // - scopeId from template context
74
+ // - slotted scopeId from slot owner
75
+ // - its own scopeId
76
+ `<span parent child-s child2></span>` +
77
+ `</div>`
66
78
)
67
79
} )
68
80
} )
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ export function renderComponentRoot(
42
42
) : VNode {
43
43
const {
44
44
type : Component ,
45
+ parent,
45
46
vnode,
46
47
proxy,
47
48
withProxy,
@@ -148,9 +149,15 @@ export function renderComponentRoot(
148
149
}
149
150
150
151
// inherit scopeId
151
- if ( vnode . scopeId ) {
152
- root = cloneVNode ( root , { [ vnode . scopeId ] : '' } )
152
+ const scopeId = vnode . scopeId
153
+ if ( scopeId ) {
154
+ root = cloneVNode ( root , { [ scopeId ] : '' } )
153
155
}
156
+ const treeOwnerId = parent && parent . type . __scopeId
157
+ if ( treeOwnerId && treeOwnerId !== scopeId ) {
158
+ root = cloneVNode ( root , { [ treeOwnerId + '-s' ] : '' } )
159
+ }
160
+
154
161
// inherit directives
155
162
if ( vnode . dirs ) {
156
163
if ( __DEV__ && ! isElementRoot ( root ) ) {
You can’t perform that action at this time.
0 commit comments