Skip to content

contrib/microevent.js -- trigger() may reference undefined property #1856

Closed
@rotdrop

Description

@rotdrop

I ran in a small problem when destroying the selectize instance an an on-change event handler. The reason is that

trigger: function(event /* , args... */){
this._events = this._events || {};
if (event in this._events === false) return;
for (var i = 0; i < this._events[event].length; i++){
this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
}
}

does not handle the case when the event-handler destroys the "this" object. In this case the "this" object is still there (as it is still referenced here), but its _events property is gone. See pull request #1855.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions