Skip to content

Commit 0a769b9

Browse files
committed
fix #613 v-repeat object fail on multiple invocations
1 parent f3074a1 commit 0a769b9

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/directive.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,20 @@ p._bind = function (def) {
6767
(!this.isLiteral || this._isDynamicLiteral) &&
6868
!this._checkStatement()
6969
) {
70-
// use raw expression as identifier because filters
71-
// make them different watchers
72-
var watcher = this.vm._watchers[this.raw]
7370
// wrapped updater for context
7471
var dir = this
7572
var update = this._update = function (val, oldVal) {
7673
if (!dir._locked) {
7774
dir.update(val, oldVal)
7875
}
7976
}
80-
if (!watcher) {
77+
// use raw expression as identifier because filters
78+
// make them different watchers
79+
var watcher = this.vm._watchers[this.raw]
80+
// v-repeat always creates a new watcher because it has
81+
// a special filter that's bound to its directive
82+
// instance.
83+
if (!watcher || this.name === 'repeat') {
8184
watcher = this.vm._watchers[this.raw] = new Watcher(
8285
this.vm,
8386
this._watcherExp,

src/directives/repeat.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ module.exports = {
1818
// uid as a cache identifier
1919
this.id = '__v_repeat_' + (++uid)
2020
// we need to insert the objToArray converter
21-
// as the first read filter.
21+
// as the first read filter, because it has to be invoked
22+
// before any user filters. (can't do it in `update`)
2223
if (!this.filters) {
2324
this.filters = {}
2425
}

0 commit comments

Comments
 (0)