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

Fixed a bug preventing bean from firing namespaced events when there are no handlers #15

Merged
merged 1 commit into from Jul 1, 2011
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
2 changes: 1 addition & 1 deletion src/bean.js
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions tests/tests.js
Expand Up @@ -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);
Expand Down