Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// if a module is provided
// pass in a special callback
// function that checks the
// module
if (module) {
if (!listenerMap[name]) listenerMap[name] = [];
l = listenerMap[name].push({
orig: cb,
cb: function() {
if (this.event.target.module() === module) {
cb.apply(this, arguments);
}
}
});
events.prototype.on.call(this, name, listenerMap[name][l-1].cb);
} else {
events.prototype.on.call(this, name, cb);
}
return this;
};
// If a callback provided, keep it
// in the listener map if it doesn't match
if (cb && map.orig !== cb) {
return true;
// Otherwise remove it from the listener
// map and unbind the event listener
} else {
events.prototype.off.call(this, name, map.cb);
return false;
}
}, this);
}
if (!module) {
events.prototype.off.call(this, name, cb);
}
return this;
};
function propagate(view, args, event) {
if (!view || !event.propagate) return;
view.event = event;
events.prototype.fire.apply(view, args);
propagate(view.parent, args, event);
}