Skip to content

Commit

Permalink
pass arguments through to custom events on fire with spec
Browse files Browse the repository at this point in the history
  • Loading branch information
fat committed Jul 13, 2011
1 parent 6d9ff64 commit 8b8851a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bean.js
Expand Up @@ -48,7 +48,7 @@
customHandler = function (element, fn, type, condition, args) {
return function (event) {
if (condition ? condition.call(this, event) : W3C_MODEL ? true : event && event.propertyName == '_on' + type || !event) {
fn.apply(element, [event].concat(args));
fn.apply(element, Array.prototype.slice.apply(arguments).concat(args));
}
};
},
Expand Down
13 changes: 13 additions & 0 deletions tests/tests.js
Expand Up @@ -130,6 +130,19 @@ sink('fire', function (test, ok) {
bean.fire(el, 'mousedown mouseup');
});

test('fire: should be able to pass multiple arguments to fired event', 4, function () {
// jquery like array syntax
var el = document.getElementById('input');
bean.remove(el);
bean.add(el, 'foo', function (one, two, three) {
ok(arguments.length == 3, 'fires an event with 3 arguments')
ok(one == 1, 'value should equal 1')
ok(two == 2, 'value should equal 2')
ok(three == 3, 'value should equal 3')
});
bean.fire(el, 'foo', [1, 2, 3]);
});

})

sink('custom', function (test, ok) {
Expand Down

0 comments on commit 8b8851a

Please sign in to comment.