Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add $arguments variable in component events inline statement #1945 #1949

Merged
merged 3 commits into from
Dec 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/instance/api/data.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 {
Expand Down
18 changes: 18 additions & 0 deletions test/unit/specs/instance/events_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,24 @@ describe('Instance Events', function () {
expect(vm.a).toBe(1)
})

it('passing $arguments', function () {
new Vue({
el: document.createElement('div'),
template: '<comp @ready="onReady($arguments[1])"></comp>',
methods: {
onReady: spy
},
components: {
comp: {
compiled: function () {
this.$emit('ready', 123, 1234)
}
}
}
})
expect(spy).toHaveBeenCalledWith(1234)
})

describe('attached/detached', function () {

it('in DOM', function () {
Expand Down