Skip to content

Commit e087e58

Browse files
committed
fix transcluded inline v-repeat scope (fix vuejs#1010)
1 parent 8bade93 commit e087e58

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/api/child.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ exports.$addChild = function (opts, BaseCtor) {
3434
)()
3535
ChildVue.options = BaseCtor.options
3636
ChildVue.linker = BaseCtor.linker
37-
ChildVue.prototype = this
37+
// important: transcluded inline repeaters should
38+
// inherit from outer scope rather than host
39+
ChildVue.prototype = opts._context || this
3840
ctors[BaseCtor.cid] = ChildVue
3941
}
4042
} else {

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,36 @@ describe('Content Transclusion', function () {
287287
})
288288
})
289289

290+
// #1010
291+
it('v-repeat inside transcluded content', function () {
292+
vm = new Vue({
293+
el: el,
294+
template:
295+
'<testa>' +
296+
'{{inner}} {{outer}}' +
297+
'<div v-repeat="list"> {{inner}} {{outer}}</div>' +
298+
'</testa>',
299+
data: {
300+
outer: 'outer',
301+
inner: 'parent-inner',
302+
list: [
303+
{ inner: 'list-inner' }
304+
]
305+
},
306+
components: {
307+
testa: {
308+
data: function () {
309+
return {
310+
inner: 'component-inner'
311+
}
312+
},
313+
template: '<content></content>'
314+
}
315+
}
316+
})
317+
expect(el.textContent).toBe('parent-inner outer list-inner outer')
318+
})
319+
290320
it('single content outlet with replace: true', function () {
291321
vm = new Vue({
292322
el: el,

0 commit comments

Comments
 (0)