Skip to content

fix #707: v-repeat nested repeats on object #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/directives/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ module.exports = {
}
var raw = this.converted ? data.value : data
var alias = this.arg
var hasAlias = !isPlainObject(raw) || alias
var hasAlias = !isObject(raw) || !isPlainObject(data) || alias
// wrap the raw data with alias
data = hasAlias ? {} : raw
if (alias) {
Expand Down
22 changes: 22 additions & 0 deletions test/unit/specs/directives/repeat_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,28 @@ if (_.inBrowser) {
)
})

it('nested repeats on object', function(){
var vm = new Vue({
el: el,
data: {
listHash: {
listA: [{a: 1},{a: 2}],
listB: [{a: 1},{a: 2}]
}
},
template: '<div v-repeat="listHash">{{$key}}' +
'<p v-repeat="$data">{{a}}</p>' +
'</div>'
})
function output(key){
var key1 = key === 'listA' ? 'listB' : 'listA'
return '<div>'+ key +'<p>1</p><p>2</p><!--v-repeat--></div>' +
'<div>'+ key1 +'<p>1</p><p>2</p><!--v-repeat--></div>' +
'<!--v-repeat-->'
}
expect(el.innerHTML === output('listA') || el.innerHTML === output('listB')).toBeTruthy()
})

it('dynamic component type based on instance data', function () {
var vm = new Vue({
el: el,
Expand Down