Skip to content

Commit

Permalink
EventDispatcher: obtain _listeners before if (#30328)
Browse files Browse the repository at this point in the history
  • Loading branch information
erasta authored Jan 15, 2025
1 parent accd150 commit 782b621
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/EventDispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ class EventDispatcher {

hasEventListener( type, listener ) {

if ( this._listeners === undefined ) return false;

const listeners = this._listeners;

if ( listeners === undefined ) return false;

return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;

}

removeEventListener( type, listener ) {

if ( this._listeners === undefined ) return;

const listeners = this._listeners;

if ( listeners === undefined ) return;

const listenerArray = listeners[ type ];

if ( listenerArray !== undefined ) {
Expand All @@ -57,9 +58,10 @@ class EventDispatcher {

dispatchEvent( event ) {

if ( this._listeners === undefined ) return;

const listeners = this._listeners;

if ( listeners === undefined ) return;

const listenerArray = listeners[ event.type ];

if ( listenerArray !== undefined ) {
Expand Down

0 comments on commit 782b621

Please sign in to comment.