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 = {
7373 const elseBlock = document . createElement ( 'template' )
7474 elseBlock . setAttribute ( 'v-else' , '' )
7575 elseBlock . innerHTML = this . el . innerHTML
76+ // the else block should be compiled in child scope
77+ elseBlock . _context = this . vm
7678 content . appendChild ( elseBlock )
7779 }
7880 const scope = host
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export default {
1919 var next = el . nextElementSibling
2020 if ( next && getAttr ( next , 'v-else' ) !== null ) {
2121 remove ( next )
22- this . elseFactory = new FragmentFactory ( this . vm , next )
22+ this . elseFactory = new FragmentFactory ( next . _context || this . vm , next )
2323 }
2424 // check main block
2525 this . anchor = createAnchor ( 'v-if' )
Original file line number Diff line number Diff line change @@ -401,12 +401,16 @@ describe('Slot Distribution', function () {
401401 var vm = new Vue ( {
402402 el : el ,
403403 data : {
404- ok : false
404+ ok : false ,
405+ msg : 'inserted'
405406 } ,
406- template : '<div><comp><div v-if="ok">inserted </div></comp></div>' ,
407+ template : '<div><comp><div v-if="ok">{{ msg }} </div></comp></div>' ,
407408 components : {
408409 comp : {
409- template : '<div><slot>fallback</slot></div>'
410+ data : function ( ) {
411+ return { msg : 'fallback' }
412+ } ,
413+ template : '<div><slot>{{ msg }}</slot></div>'
410414 }
411415 }
412416 } )
You can’t perform that action at this time.
0 commit comments