File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
test/unit/specs/element-directives Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,11 @@ module.exports = {
8181
8282 compile : function ( content , context , host ) {
8383 if ( content && context ) {
84+ var scope = host
85+ ? host . _scope
86+ : this . _scope
8487 this . unlink = context . $compile (
85- content , host , this . vm . _scope , this . _frag
88+ content , host , scope , this . _frag
8689 )
8790 }
8891 if ( content ) {
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ describe('Slot Distribution', function () {
77 beforeEach ( function ( ) {
88 el = document . createElement ( 'div' )
99 options = {
10- el : el
10+ el : el ,
11+ data : {
12+ msg : 'self'
13+ }
1114 }
1215 } )
1316
@@ -39,10 +42,10 @@ describe('Slot Distribution', function () {
3942 } )
4043
4144 it ( 'fallback content' , function ( ) {
42- options . template = '<slot><p>fallback </p></slot>'
45+ options . template = '<slot><p>{{msg}} </p></slot>'
4346 mount ( )
4447 expect ( el . firstChild . tagName ) . toBe ( 'P' )
45- expect ( el . firstChild . textContent ) . toBe ( 'fallback ' )
48+ expect ( el . firstChild . textContent ) . toBe ( 'self ' )
4649 } )
4750
4851 it ( 'fallback content with multiple named slots' , function ( ) {
@@ -363,4 +366,22 @@ describe('Slot Distribution', function () {
363366 expect ( el . textContent ) . toBe ( '123234' )
364367 } )
365368
369+ it ( 'fallback inside v-for' , function ( ) {
370+ new Vue ( {
371+ el : el ,
372+ template : '<div v-for="n in 3"><comp></comp></div>' ,
373+ components : {
374+ comp : {
375+ template : '<div><slot>{{something}}</slot></div>' ,
376+ data : function ( ) {
377+ return {
378+ something : 'hi'
379+ }
380+ }
381+ }
382+ }
383+ } )
384+ expect ( el . textContent ) . toBe ( 'hihihi' )
385+ } )
386+
366387} )
You can’t perform that action at this time.
0 commit comments