rhyzx 10 лет назад
Родитель
Сommit
68423feb40
2 измененных файлов с 7 добавлено и 10 удалено
  1. 3 1
      src/instance/api/data.js
  2. 4 9
      src/instance/internal/events.js

+ 3 - 1
src/instance/api/data.js

@@ -1,5 +1,5 @@
 import Watcher from '../../watcher'
-import { del } from '../../util/index'
+import { del, toArray } from '../../util/index'
 import { parseText } from '../../parsers/text'
 import { parseDirective } from '../../parsers/directive'
 import { getPath } from '../../parsers/path'
@@ -23,7 +23,9 @@ export default function (Vue) {
       if (asStatement && !isSimplePath(exp)) {
         var self = this
         return function statementHandler () {
+          self.$arguments = toArray(arguments)
           res.get.call(self, self)
+          self.$arguments = null
         }
       } else {
         try {

+ 4 - 9
src/instance/internal/events.js

@@ -32,18 +32,13 @@ export default function (Vue) {
 
   function registerComponentEvents (vm, el) {
     var attrs = el.attributes
+    var name, handler
     for (var i = 0, l = attrs.length; i < l; i++) {
-      let name = attrs[i].name
+      name = attrs[i].name
       if (eventRE.test(name)) {
         name = name.replace(eventRE, '')
-        const scope = vm._scope || vm._context
-        const handler = scope.$eval(attrs[i].value, true)
-        vm.$on(name.replace(eventRE), function (...args) {
-          scope.$arguments = args
-          const result = handler.apply(this, args)
-          scope.$arguments = null
-          return result
-        })
+        handler = (vm._scope || vm._context).$eval(attrs[i].value, true)
+        vm.$on(name.replace(eventRE), handler)
       }
     }
   }