Skip to content

Commit a8cb815

Browse files
committed
fix slot compilation scope inside v-for (fix #1268)
1 parent 6f112ff commit a8cb815

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/directives/element/slot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = {
6363
compile: function (content, context, host) {
6464
if (content && context) {
6565
this.unlink = context.$compile(
66-
content, host, this._scope, this._frag
66+
content, host, this.vm._scope, this._frag
6767
)
6868
}
6969
if (content) {

test/unit/specs/directives/element/slot_spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,20 @@ describe('Slot Distribution', function () {
348348
expect(el.innerHTML).toBe('hello world')
349349
})
350350

351+
it('inside v-for', function () {
352+
var vm = new Vue({
353+
el: el,
354+
template: '<comp v-for="item in items">{{item.value}}</comp>',
355+
data: {
356+
items: [{value: 123}, {value: 234}]
357+
},
358+
components: {
359+
comp: {
360+
tempalte: '<div><slot></slot></div>'
361+
}
362+
}
363+
})
364+
expect(el.textContent).toBe('123234')
365+
})
366+
351367
})

0 commit comments

Comments
 (0)