From 0a769b9db68f5a4528dd5f8380afe6324d1d96d3 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 1 Dec 2014 20:46:01 -0500 Subject: [PATCH] fix #613 v-repeat object fail on multiple invocations --- src/directive.js | 11 +++++++---- src/directives/repeat.js | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/directive.js b/src/directive.js index c17bbeaf17e..6abdcdfce0c 100644 --- a/src/directive.js +++ b/src/directive.js @@ -67,9 +67,6 @@ 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) { @@ -77,7 +74,13 @@ p._bind = function (def) { 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, diff --git a/src/directives/repeat.js b/src/directives/repeat.js index b98513def38..bf0f33fc91e 100644 --- a/src/directives/repeat.js +++ b/src/directives/repeat.js @@ -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 = {} }