Skip to content

Commit

Permalink
fix(on): allows multiple spaces in event string
Browse files Browse the repository at this point in the history
  • Loading branch information
davestevens committed Sep 7, 2015
1 parent ab50527 commit b89bd0e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/nipplejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,14 @@ var Nipple = function (options) {
// Basic event system.
Nipple.prototype.on = function (type, cb) {
var self = this;
var types = type.split(/[ ,]/g);
var types = type.split(/[ ,]+/g);
var type;

if (types.length > 1) {
for (var i = 0, max = types.length; i < max; i += 1) {
self.on(types[i], cb);
}
return self;
for (var i = 0; i < types.length; i += 1) {
type = types[i];
self.handlers[type] = self.handlers[type] || [];
self.handlers[type].push(cb);
}

self.handlers[type] = self.handlers[type] || [];
self.handlers[type].push(cb);
return self;
};

Expand Down

0 comments on commit b89bd0e

Please sign in to comment.