@@ -14,7 +14,8 @@ export function initRender (vm: Component) {
14
14
vm . $vnode = null // the placeholder node in parent tree
15
15
vm . _vnode = null // the root of the child tree
16
16
vm . _staticTrees = null
17
- vm . $slots = resolveSlots ( vm . $options . _renderChildren )
17
+ vm . _renderContext = vm . $options . _parentVnode && vm . $options . _parentVnode . context
18
+ vm . $slots = resolveSlots ( vm . $options . _renderChildren , vm . _renderContext )
18
19
// bind the public createElement fn to this instance
19
20
// so that we get proper render context inside it.
20
21
vm . $createElement = bind ( createElement , vm )
@@ -215,7 +216,8 @@ export function renderMixin (Vue: Class<Component>) {
215
216
}
216
217
217
218
export function resolveSlots (
218
- renderChildren : ?VNodeChildren
219
+ renderChildren : ?VNodeChildren ,
220
+ context : ?Component
219
221
) : { [ key : string ] : Array < VNode > } {
220
222
const slots = { }
221
223
if ( ! renderChildren ) {
@@ -226,8 +228,10 @@ export function resolveSlots (
226
228
let name , child
227
229
for ( let i = 0 , l = children . length ; i < l ; i ++ ) {
228
230
child = children [ i ]
229
- if ( child . data && ( name = child . data . slot ) ) {
230
- delete child . data . slot
231
+ // named slots should only be respected if the vnode was rendered in the
232
+ // same context.
233
+ if ( child . context === context &&
234
+ child . data && ( name = child . data . slot ) ) {
231
235
const slot = ( slots [ name ] || ( slots [ name ] = [ ] ) )
232
236
if ( child . tag === 'template' ) {
233
237
slot . push . apply ( slot , child . children )
0 commit comments