Skip to content

Commit 264d89a

Browse files
committed
fix slot compilation scope inside v-for (fix #1268)
1 parent b12a455 commit 264d89a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/element-directives/slot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = {
8282
compile: function (content, context, host) {
8383
if (content && context) {
8484
this.unlink = context.$compile(
85-
content, host, this._scope, this._frag
85+
content, host, this.vm._scope, this._frag
8686
)
8787
}
8888
if (content) {

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

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

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

0 commit comments

Comments
 (0)