Skip to content

Commit a38012b

Browse files
committed
fix vuejs#822: v-repeat & custom element components
1 parent 7f7e36b commit a38012b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/directives/repeat.js

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ module.exports = {
114114
merged._asComponent = true
115115
merged._parent = this.vm
116116
this.template = transclude(this.template, merged)
117+
// Important: mark the template as a root node so that
118+
// custom element components don't get compiled twice.
119+
// fixes #822
120+
this.template.__vue__ = true
117121
this._linkFn = compile(this.template, merged)
118122
} else {
119123
// to be resolved later

test/unit/specs/directives/repeat_spec.js

+21
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,27 @@ if (_.inBrowser) {
210210
})
211211

212212
it('custom element component', function () {
213+
var vm = new Vue({
214+
el: el,
215+
data: {
216+
items: [{a:1}, {a:2}, {a:3}]
217+
},
218+
template: '<test-component v-repeat="items"></test-component>',
219+
components: {
220+
'test-component': {
221+
template: '{{$index}} {{a}}'
222+
}
223+
}
224+
})
225+
expect(el.innerHTML).toBe(
226+
'<test-component>0 1</test-component>' +
227+
'<test-component>1 2</test-component>' +
228+
'<test-component>2 3</test-component>' +
229+
'<!--v-repeat-->'
230+
)
231+
})
232+
233+
it('custom element component with replace:true', function () {
213234
var vm = new Vue({
214235
el: el,
215236
data: {

0 commit comments

Comments
 (0)