Skip to content

Commit 1c87165

Browse files
committed
use simpler syntax guard for v-repeat
1 parent 215949b commit 1c87165

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

src/directive.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ function Directive (name, el, vm, descriptor, def, host) {
2727
this.name = name
2828
this.el = el
2929
this.vm = vm
30-
if (def._guard) {
31-
def._guard(descriptor)
32-
}
3330
// copy descriptor props
3431
this.raw = descriptor.raw
3532
this.expression = descriptor.expression

src/directives/repeat.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ module.exports = {
2020
*/
2121

2222
bind: function () {
23+
// support for item in array syntax
24+
var inMatch = this.expression.match(/(.*) in (.*)/)
25+
if (inMatch) {
26+
this.arg = inMatch[1]
27+
this._watcherExp = inMatch[2]
28+
}
2329
// uid as a cache identifier
2430
this.id = '__v_repeat_' + (++uid)
2531
// setup anchor nodes
@@ -678,24 +684,7 @@ module.exports = {
678684
this.converted = true
679685
return res
680686
}
681-
},
682-
683-
/**
684-
* Internal hook to do custom transform on the directive's
685-
* descriptor so that it can support special syntax.
686-
*
687-
* @param {Object} descriptor
688-
*/
689-
690-
_guard: function (descriptor) {
691-
var exp = descriptor.expression
692-
var match = exp.trim().match(/(.*) in (.*)/)
693-
if (match) {
694-
descriptor.arg = match[1]
695-
descriptor.expression = match[2]
696-
}
697687
}
698-
699688
}
700689

701690
/**

0 commit comments

Comments
 (0)