Skip to content

Commit

Permalink
fix vuejs#613 v-repeat object fail on multiple invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 2, 2014
1 parent f3074a1 commit 0a769b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@ p._bind = function (def) {
(!this.isLiteral || this._isDynamicLiteral) &&
!this._checkStatement()
) {
// use raw expression as identifier because filters
// make them different watchers
var watcher = this.vm._watchers[this.raw]
// wrapped updater for context
var dir = this
var update = this._update = function (val, oldVal) {
if (!dir._locked) {
dir.update(val, oldVal)
}
}
if (!watcher) {
// use raw expression as identifier because filters
// make them different watchers
var watcher = this.vm._watchers[this.raw]
// v-repeat always creates a new watcher because it has
// a special filter that's bound to its directive
// instance.
if (!watcher || this.name === 'repeat') {
watcher = this.vm._watchers[this.raw] = new Watcher(
this.vm,
this._watcherExp,
Expand Down
3 changes: 2 additions & 1 deletion src/directives/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = {
// uid as a cache identifier
this.id = '__v_repeat_' + (++uid)
// we need to insert the objToArray converter
// as the first read filter.
// as the first read filter, because it has to be invoked
// before any user filters. (can't do it in `update`)
if (!this.filters) {
this.filters = {}
}
Expand Down

0 comments on commit 0a769b9

Please sign in to comment.