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 = {
81
81
82
82
compile : function ( content , context , host ) {
83
83
if ( content && context ) {
84
+ var scope = host
85
+ ? host . _scope
86
+ : this . _scope
84
87
this . unlink = context . $compile (
85
- content , host , this . vm . _scope , this . _frag
88
+ content , host , scope , this . _frag
86
89
)
87
90
}
88
91
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 ( ) {
@@ -363,4 +366,22 @@ describe('Slot Distribution', function () {
363
366
expect ( el . textContent ) . toBe ( '123234' )
364
367
} )
365
368
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
+
366
387
} )
You can’t perform that action at this time.
0 commit comments