Skip to content

Commit 5fb9f24

Browse files
committed
still need to check conversion in v-repeat update
1 parent 2859377 commit 5fb9f24

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/directives/repeat.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,12 @@ module.exports = {
140140
this.vm.$[this.childId] = this.vms
141141
}
142142

143+
// If the collection is not already converted for observation,
144+
// we need to convert and watch it.
145+
if (!Observer.convert(collection)) {
146+
Observer.watch(collection)
147+
}
143148
// listen for collection mutation events
144-
// the collection has been augmented during Binding.set()
145149
collection.__emitter__.on('mutate', this.mutationListener)
146150

147151
// create new VMs and append to DOM
@@ -397,8 +401,6 @@ function objectToArray (obj) {
397401
def(data, '$key', key)
398402
res.push(data)
399403
}
400-
Observer.convert(res)
401-
Observer.watch(res)
402404
return res
403405
}
404406

src/observer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function isWatchable (obj) {
178178
* Convert an Object/Array to give it a change emitter.
179179
*/
180180
function convert (obj) {
181-
if (obj.__emitter__) return false
181+
if (obj.__emitter__) return true
182182
var emitter = new Emitter()
183183
def(obj, '__emitter__', emitter)
184184
emitter.on('set', function () {
@@ -190,7 +190,7 @@ function convert (obj) {
190190
})
191191
emitter.values = utils.hash()
192192
emitter.owners = []
193-
return true
193+
return false
194194
}
195195

196196
/**
@@ -358,7 +358,7 @@ function observe (obj, rawPath, observer) {
358358
if (!isWatchable(obj)) return
359359

360360
var path = rawPath ? rawPath + '.' : '',
361-
alreadyConverted = !convert(obj),
361+
alreadyConverted = convert(obj),
362362
emitter = obj.__emitter__
363363

364364
// setup proxy listeners on the parent observer.

0 commit comments

Comments
 (0)