Skip to content

clearListeners throws an error when called on an uninitialised emitr #9

@avsmithy

Description

@avsmithy

clearListeners() does not check for the existence of the _emitterListeners property before calling _emitterListeners.filterAll(). If _emitterListeners is undefined, it throws an error.

clearListeners: function clearListeners(context) {
...
    this._emitterListeners.filterAll(function(record) {
...
}

off() checks for _emitterListeners, so using off(null, null, this), which calls clearListeners(), works as expected.

off: function off(eventIdentifier, callback, context) {
    // not initialised - so no listeners of any kind
    if (this._emitterListeners == null) { return false; }
... 
...
        this.clearListeners(this);
...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions