Skip to content
Browse files

Merge pull request #15 from antonkovalyov/master

Fixed a bug preventing bean from firing namespaced events when there are no handlers
  • Loading branch information...
2 parents 5148e11 + 989bff0 commit ad44197470d64bac164cfd52069e86d55140678b @fat committed Jun 30, 2011
Showing with 13 additions and 1 deletion.
  1. +1 −1 src/bean.js
  2. +12 −0 tests/tests.js
View
2 src/bean.js
@@ -175,7 +175,7 @@
if (isNamespace) {
isNamespace = isNamespace.split('.');
for (k = isNamespace.length; k--;) {
- handlers[isNamespace[k]] && handlers[isNamespace[k]].apply(element, args);
+ handlers && handlers[isNamespace[k]] && handlers[isNamespace[k]].apply(element, args);
}
} else if (!args && element[eventSupport]) {
fireListener(isNative, type, element);
View
12 tests/tests.js
@@ -369,6 +369,18 @@ sink('namespaces', function (test, ok) {
Syn.click(el1);
});
+ test('namespace: should be able to fire an event without handlers', 1, function () {
+ var el1 = document.getElementById('foo'), succ;
+ bean.remove(el1);
+ try {
+ bean.fire(el1, 'click.fat');
+ succ = true;
+ } catch (exc) {
+ succ = false;
+ }
+ ok(succ, 'fire namespaced event with no handlers');
+ });
+
test('namespace: should be able to target namespaced event handlers with fire', 1, function () {
var el1 = document.getElementById('foo');
bean.remove(el1);

0 comments on commit ad44197

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