Simplify Emitter.inject() a bit, as we only need to handle _events in the first injection scope.

This commit is contained in:
Jürg Lehni 2014-10-21 23:52:53 +02:00
parent a39eea64e9
commit bfd3a91df0

View file

@ -114,10 +114,10 @@ var Emitter = {
statics: {
// Override inject() so that sub-classes automatically add the accessors
// for the event handler functions (e.g. #onMouseDown) for each property
inject: function inject(/* src, ... */) {
for (var i = 0, l = arguments.length; i < l; i++) {
var src = arguments[i],
events = src._events;
// NOTE: This needs to be defined in the first injection scope, as for
// simplicity, we don't loop through all of them here.
inject: function inject(src) {
var events = src._events;
if (events) {
// events can either be an object literal or an array of
// strings describing the on*-names.
@ -149,9 +149,7 @@ var Emitter = {
});
src._eventTypes = types;
}
inject.base.call(this, src);
}
return this;
return inject.base.apply(this, arguments);
}
}
};