Skip to content

Commit

Permalink
[lib] wildcard bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
hij1nx committed Jul 26, 2011
1 parent 4dd40d6 commit 7fdc052
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 4 additions & 5 deletions lib/eventemitter2.js
Expand Up @@ -52,9 +52,8 @@
}
}

if(tree && (type[i] === '*' || tree[type[i]])) {

if(type[i] === '*') {
if(tree && (type[i] === '*' || tree[type[i]] || tree['*'])) {
if(type[i] === '*' || tree['*']) {
for(var branch in tree) {
if(tree.hasOwnProperty(branch)) {
listeners = searchListenerTree(handlers, type, tree[branch], i+1);
Expand All @@ -81,7 +80,7 @@
};

var growListenerTree = function(type, listener) {

var d = this.delimiter;

if (type.charAt(0) === d ||
Expand All @@ -98,7 +97,7 @@
while (name) {

if (!tree[name]) {
tree[name] = new Object();
tree[name] = new Object;
}

tree = tree[name];
Expand Down
5 changes: 2 additions & 3 deletions test/wildcardEvents/addListener.js
Expand Up @@ -144,14 +144,13 @@ module.exports = simpleEvents({
var emitter = this.emitter;
var type = '*.*';
var f = function () {
text.ok(true, 'the event was fired')
test.ok(true, 'the event was fired')
};

emitter.on(type, f);
console.log(emitter._events)
emitter.emit('foo.foo');

test.expect(2);
test.expect(1);
test.done();
}

Expand Down

0 comments on commit 7fdc052

Please sign in to comment.