diff --git a/src/util/evented.js b/src/util/evented.js index c29bffef346..322eb3e40df 100644 --- a/src/util/evented.js +++ b/src/util/evented.js @@ -149,14 +149,14 @@ export class Evented { } /** - * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type. + * Returns true if this instance of Evented or any forwarded instances of Evented have a listener for the specified type. * * @param {string} type The event type * @returns {boolean} `true` if there is at least one registered listener for specified event type, `false` otherwise * @private */ listens(type: string) { - return ( + return !!( (this._listeners && this._listeners[type] && this._listeners[type].length > 0) || (this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0) || (this._eventedParent && this._eventedParent.listens(type)) diff --git a/test/unit/util/evented.test.js b/test/unit/util/evented.test.js index ff6c6e97adb..62fbe2cc87f 100644 --- a/test/unit/util/evented.test.js +++ b/test/unit/util/evented.test.js @@ -93,7 +93,7 @@ test('Evented', (t) => { const evented = new Evented(); evented.on('a', () => {}); t.ok(evented.listens('a')); - t.notOk(evented.listens('b')); + t.equals(evented.listens('b'), false); t.end(); });