Skip to content
Browse files

pass arguments through to custom events on fire with spec

  • Loading branch information...
1 parent 6d9ff64 commit 8b8851ad1ee2fe1272903be30d44113283252c98 @fat committed
Showing with 14 additions and 1 deletion.
  1. +1 −1 src/bean.js
  2. +13 −0 tests/tests.js
View
2 src/bean.js
@@ -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));
}
};
},
View
13 tests/tests.js
@@ -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) {

0 comments on commit 8b8851a

Please sign in to comment.
Something went wrong with that request. Please try again.