File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
test/unit/specs/directives/element Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,11 @@ module.exports = {
62
62
63
63
compile : function ( content , context , host ) {
64
64
if ( content && context ) {
65
+ var scope = host
66
+ ? host . _scope
67
+ : this . _scope
65
68
this . unlink = context . $compile (
66
- content , host , this . vm . _scope , this . _frag
69
+ content , host , scope , this . _frag
67
70
)
68
71
}
69
72
if ( content ) {
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ describe('Slot Distribution', function () {
7
7
beforeEach ( function ( ) {
8
8
el = document . createElement ( 'div' )
9
9
options = {
10
- el : el
10
+ el : el ,
11
+ data : {
12
+ msg : 'self'
13
+ }
11
14
}
12
15
} )
13
16
@@ -39,10 +42,10 @@ describe('Slot Distribution', function () {
39
42
} )
40
43
41
44
it ( 'fallback content' , function ( ) {
42
- options . template = '<slot><p>fallback </p></slot>'
45
+ options . template = '<slot><p>{{msg}} </p></slot>'
43
46
mount ( )
44
47
expect ( el . firstChild . tagName ) . toBe ( 'P' )
45
- expect ( el . firstChild . textContent ) . toBe ( 'fallback ' )
48
+ expect ( el . firstChild . textContent ) . toBe ( 'self ' )
46
49
} )
47
50
48
51
it ( 'fallback content with multiple named slots' , function ( ) {
@@ -364,4 +367,22 @@ describe('Slot Distribution', function () {
364
367
expect ( el . textContent ) . toBe ( '123234' )
365
368
} )
366
369
370
+ it ( 'fallback inside v-for' , function ( ) {
371
+ new Vue ( {
372
+ el : el ,
373
+ template : '<div v-for="n in 3"><comp></comp></div>' ,
374
+ components : {
375
+ comp : {
376
+ template : '<div><slot>{{something}}</slot></div>' ,
377
+ data : function ( ) {
378
+ return {
379
+ something : 'hi'
380
+ }
381
+ }
382
+ }
383
+ }
384
+ } )
385
+ expect ( el . textContent ) . toBe ( 'hihihi' )
386
+ } )
387
+
367
388
} )
You can’t perform that action at this time.
0 commit comments