Skip to content

Commit ab254f7

Browse files
committed
fix v-repeat on array of arrays without identifier
1 parent 9013fbb commit ab254f7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/directives/repeat.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var _ = require('../util')
22
var isObject = _.isObject
3+
var isPlainObject = _.isPlainObject
34
var textParser = require('../parsers/text')
45
var expParser = require('../parsers/expression')
56
var templateParser = require('../parsers/template')
@@ -267,7 +268,7 @@ module.exports = {
267268
}
268269
var raw = this.converted ? data.value : data
269270
var alias = this.arg
270-
var hasAlias = !isObject(raw) || alias
271+
var hasAlias = !isPlainObject(raw) || alias
271272
// wrap the raw data with alias
272273
data = hasAlias ? {} : raw
273274
if (alias) {
@@ -467,7 +468,7 @@ function findNextVm (vm, ref) {
467468
*/
468469

469470
function objToArray (obj) {
470-
if (!_.isPlainObject(obj)) {
471+
if (!isPlainObject(obj)) {
471472
return obj
472473
}
473474
var keys = Object.keys(obj)

test/unit/specs/directives/repeat_spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ if (_.inBrowser) {
110110
assertObjectPrimitiveMutations(vm, el, done)
111111
})
112112

113+
it('array of arrays', function () {
114+
var vm = new Vue({
115+
el: el,
116+
data: {
117+
items: [[1,1], [2,2], [3,3]]
118+
},
119+
template: '<div v-repeat="items">{{$index}} {{$value}}</div>'
120+
})
121+
var markup = vm.items.map(function (item, i) {
122+
return '<div>' + i + ' ' + item.toString() + '</div>'
123+
}).join('') + '<!--v-repeat-->'
124+
expect(el.innerHTML).toBe(markup)
125+
})
126+
113127
it('repeating object with filter', function () {
114128
var vm = new Vue({
115129
el: el,

0 commit comments

Comments
 (0)