@@ -14,7 +14,8 @@ export function initRender (vm: Component) {
1414 vm . $vnode = null // the placeholder node in parent tree
1515 vm . _vnode = null // the root of the child tree
1616 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 )
1819 // bind the public createElement fn to this instance
1920 // so that we get proper render context inside it.
2021 vm . $createElement = bind ( createElement , vm )
@@ -215,7 +216,8 @@ export function renderMixin (Vue: Class<Component>) {
215216}
216217
217218export function resolveSlots (
218- renderChildren : ?VNodeChildren
219+ renderChildren : ?VNodeChildren ,
220+ context : ?Component
219221) : { [ key : string ] : Array < VNode > } {
220222 const slots = { }
221223 if ( ! renderChildren ) {
@@ -226,8 +228,10 @@ export function resolveSlots (
226228 let name , child
227229 for ( let i = 0 , l = children . length ; i < l ; i ++ ) {
228230 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 ) ) {
231235 const slot = ( slots [ name ] || ( slots [ name ] = [ ] ) )
232236 if ( child . tag === 'template' ) {
233237 slot . push . apply ( slot , child . children )
0 commit comments