Skip to content

Commit 68423fe

Browse files
committed
optimise $arguments passing
1 parent 978c86a commit 68423fe

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/instance/api/data.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Watcher from '../../watcher'
2-
import { del } from '../../util/index'
2+
import { del, toArray } from '../../util/index'
33
import { parseText } from '../../parsers/text'
44
import { parseDirective } from '../../parsers/directive'
55
import { getPath } from '../../parsers/path'
@@ -23,7 +23,9 @@ export default function (Vue) {
2323
if (asStatement && !isSimplePath(exp)) {
2424
var self = this
2525
return function statementHandler () {
26+
self.$arguments = toArray(arguments)
2627
res.get.call(self, self)
28+
self.$arguments = null
2729
}
2830
} else {
2931
try {

src/instance/internal/events.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,13 @@ export default function (Vue) {
3232

3333
function registerComponentEvents (vm, el) {
3434
var attrs = el.attributes
35+
var name, handler
3536
for (var i = 0, l = attrs.length; i < l; i++) {
36-
let name = attrs[i].name
37+
name = attrs[i].name
3738
if (eventRE.test(name)) {
3839
name = name.replace(eventRE, '')
39-
const scope = vm._scope || vm._context
40-
const handler = scope.$eval(attrs[i].value, true)
41-
vm.$on(name.replace(eventRE), function (...args) {
42-
scope.$arguments = args
43-
const result = handler.apply(this, args)
44-
scope.$arguments = null
45-
return result
46-
})
40+
handler = (vm._scope || vm._context).$eval(attrs[i].value, true)
41+
vm.$on(name.replace(eventRE), handler)
4742
}
4843
}
4944
}

0 commit comments

Comments
 (0)