When I am off event, the events in the trigger function can't be synchronized, because the var events = this._events[name] statement in the trigger function is wrong, this._events[name] = retain = in the off function. The var events = this._events[name] in the [] statement and the trigger function are two different reference addresses.
The trigger function should be changed to:
trigger: function(name) {
if (!this._events) return this;
var args = slice.call(arguments, 1);
if (!eventsApi(this, 'trigger', name, args)) return this;
//var events = this._events[name];
var allEvents = this._events.all;
if (this._events[name]) triggerEvents(this._events[name], args);
if (allEvents) triggerEvents(allEvents, arguments);
return this;
},
When I am off event, the events in the trigger function can't be synchronized, because the var events = this._events[name] statement in the trigger function is wrong, this._events[name] = retain = in the off function. The var events = this._events[name] in the [] statement and the trigger function are two different reference addresses.
The trigger function should be changed to: