File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
test/unit/specs/directives/element Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ export const slot = {
73
73
const elseBlock = document . createElement ( 'template' )
74
74
elseBlock . setAttribute ( 'v-else' , '' )
75
75
elseBlock . innerHTML = this . el . innerHTML
76
+ // the else block should be compiled in child scope
77
+ elseBlock . _context = this . vm
76
78
content . appendChild ( elseBlock )
77
79
}
78
80
const scope = host
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export default {
19
19
var next = el . nextElementSibling
20
20
if ( next && getAttr ( next , 'v-else' ) !== null ) {
21
21
remove ( next )
22
- this . elseFactory = new FragmentFactory ( this . vm , next )
22
+ this . elseFactory = new FragmentFactory ( next . _context || this . vm , next )
23
23
}
24
24
// check main block
25
25
this . anchor = createAnchor ( 'v-if' )
Original file line number Diff line number Diff line change @@ -401,12 +401,16 @@ describe('Slot Distribution', function () {
401
401
var vm = new Vue ( {
402
402
el : el ,
403
403
data : {
404
- ok : false
404
+ ok : false ,
405
+ msg : 'inserted'
405
406
} ,
406
- template : '<div><comp><div v-if="ok">inserted </div></comp></div>' ,
407
+ template : '<div><comp><div v-if="ok">{{ msg }} </div></comp></div>' ,
407
408
components : {
408
409
comp : {
409
- template : '<div><slot>fallback</slot></div>'
410
+ data : function ( ) {
411
+ return { msg : 'fallback' }
412
+ } ,
413
+ template : '<div><slot>{{ msg }}</slot></div>'
410
414
}
411
415
}
412
416
} )
You can’t perform that action at this time.
0 commit comments