Skip to content

Commit 5b5fa61

Browse files
committed
minor tweak
1 parent ed0be36 commit 5b5fa61

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/directives/repeat.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,13 @@ module.exports = {
178178
build: function (data, index, isObject) {
179179

180180
// wrap non-object values
181-
if (!isObject || this.arg) {
182-
var raw = data
181+
var raw, alias,
182+
wrap = !isObject || this.arg
183+
if (wrap) {
184+
raw = data
185+
alias = this.arg || '$value'
183186
data = { $index: index }
184-
data[this.arg || '$value'] = raw
187+
data[alias] = raw
185188
}
186189

187190
var el = this.el.cloneNode(true),
@@ -199,14 +202,14 @@ module.exports = {
199202
utils.defProtected(data, this.identifier, true)
200203
vm.$index = index
201204

202-
if (!isObject || this.arg) {
205+
if (wrap) {
203206
var self = this,
204207
sync = function (val) {
205208
self.lock = true
206209
self.collection.$set(vm.$index, val)
207210
self.lock = false
208211
}
209-
vm.$compiler.observer.on('change:' + (this.arg || '$value'), sync)
212+
vm.$compiler.observer.on('change:' + alias, sync)
210213
}
211214

212215
return vm

0 commit comments

Comments
 (0)