Skip to content

Commit 441baf3

Browse files
committed
Merge pull request #709 from calebboyd/dev
fix #707: v-repeat nested repeats on object
2 parents a06cd65 + 7b7c2e5 commit 441baf3

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/directives/repeat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ module.exports = {
268268
}
269269
var raw = this.converted ? data.value : data
270270
var alias = this.arg
271-
var hasAlias = !isPlainObject(raw) || alias
271+
var hasAlias = !isObject(raw) || !isPlainObject(data) || alias
272272
// wrap the raw data with alias
273273
data = hasAlias ? {} : raw
274274
if (alias) {

test/unit/specs/directives/repeat_spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,28 @@ if (_.inBrowser) {
194194
)
195195
})
196196

197+
it('nested repeats on object', function(){
198+
var vm = new Vue({
199+
el: el,
200+
data: {
201+
listHash: {
202+
listA: [{a: 1},{a: 2}],
203+
listB: [{a: 1},{a: 2}]
204+
}
205+
},
206+
template: '<div v-repeat="listHash">{{$key}}' +
207+
'<p v-repeat="$data">{{a}}</p>' +
208+
'</div>'
209+
})
210+
function output(key){
211+
var key1 = key === 'listA' ? 'listB' : 'listA'
212+
return '<div>'+ key +'<p>1</p><p>2</p><!--v-repeat--></div>' +
213+
'<div>'+ key1 +'<p>1</p><p>2</p><!--v-repeat--></div>' +
214+
'<!--v-repeat-->'
215+
}
216+
expect(el.innerHTML === output('listA') || el.innerHTML === output('listB')).toBeTruthy()
217+
})
218+
197219
it('dynamic component type based on instance data', function () {
198220
var vm = new Vue({
199221
el: el,

0 commit comments

Comments
 (0)