Closed aaronmccall closed 9 years ago
This code at wildemitter.js#L131 unintentionally matches all wildcard events that have been registered:
split = item.split('*'); if (item === '*' || (split.length === 2 && eventName.slice(0, split[1].length) === split[1])) { result = result.concat(this.callbacks[item]); }
The reason: split[1] is the empty part of the string after the '*' so we're comparing a 0 length slice of eventName ("") to split1.
Simply changing to
split = item.split('*'); if (item === '*' || (split.length === 2 && eventName.slice(0, split[0].length) === split[0])) { result = result.concat(this.callbacks[item]); }
will solve the problem because now we're comparing the eventName to the part of the wildcard before the asterisk.
This code at wildemitter.js#L131 unintentionally matches all wildcard events that have been registered:
The reason: split[1] is the empty part of the string after the '*' so we're comparing a 0 length slice of eventName ("") to split1.
Simply changing to
will solve the problem because now we're comparing the eventName to the part of the wildcard before the asterisk.