Skip to content

Commit f819514

Browse files
committed
Merge pull request vuejs#1949 from rhyzx/inline-statement-variable
Add $arguments variable in component events inline statement vuejs#1945
2 parents 9ce299b + 68423fe commit f819514

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
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 {

test/unit/specs/instance/events_spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,24 @@ describe('Instance Events', function () {
237237
expect(vm.a).toBe(1)
238238
})
239239

240+
it('passing $arguments', function () {
241+
new Vue({
242+
el: document.createElement('div'),
243+
template: '<comp @ready="onReady($arguments[1])"></comp>',
244+
methods: {
245+
onReady: spy
246+
},
247+
components: {
248+
comp: {
249+
compiled: function () {
250+
this.$emit('ready', 123, 1234)
251+
}
252+
}
253+
}
254+
})
255+
expect(spy).toHaveBeenCalledWith(1234)
256+
})
257+
240258
describe('attached/detached', function () {
241259

242260
it('in DOM', function () {

0 commit comments

Comments
 (0)