Просмотр исходного кода

make todomvc e2e tests pass for v-for

Evan You 10 лет назад
Родитель
Сommit
671a329db4
3 измененных файлов с 7 добавлено и 8 удалено
  1. 1 1
      examples/todomvc/index.html
  2. 3 3
      src/directive.js
  3. 3 4
      src/directives/on.js

+ 1 - 1
examples/todomvc/index.html

@@ -20,7 +20,7 @@
 				<input class="toggle-all" type="checkbox" v-model="allDone">
 				<ul class="todo-list">
 					<li class="todo"
-						v-repeat="todo: filteredTodos"
+						v-for="todo in filteredTodos"
 						v-class="completed: todo.completed, editing: todo == editedTodo">
 						<div class="view">
 							<input class="toggle" type="checkbox" v-model="todo.completed">

+ 3 - 3
src/directive.js

@@ -144,12 +144,12 @@ Directive.prototype._checkStatement = function () {
     !expParser.isSimplePath(expression)
   ) {
     var fn = expParser.parse(expression).get
-    var vm = this.vm
+    var scope = this._scope || this.vm
     var handler = function () {
-      fn.call(vm, vm)
+      fn.call(scope, scope)
     }
     if (this.filters) {
-      handler = vm._applyFilters(handler, null, this.filters)
+      handler = this.vm._applyFilters(handler, null, this.filters)
     }
     this.update(handler)
     return true

+ 3 - 4
src/directives/on.js

@@ -29,12 +29,11 @@ module.exports = {
       return
     }
     this.reset()
-    var vm = this.vm
+    var scope = this._scope || this.vm
     this.handler = function (e) {
-      e.targetVM = vm
-      vm.$event = e
+      scope.$event = e
       var res = handler(e)
-      vm.$event = null
+      scope.$event = null
       return res
     }
     if (this.iframeBind) {