8000 fix: move cheaper check in front · NativeScript/NativeScript@2a8c926 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a8c926

Browse files
committed
fix: move cheaper check in front
1 parent decccab commit 2a8c926

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

packages/core/data/dom-events/dom-event.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,17 @@ export class DOMEvent implements Event {
393393
for (let i = this.listenersLazyCopy.length - 1; i >= 0; i--) {
394394
const listener = this.listenersLazyCopy[i];
395395

396+
// Assigning variables this old-fashioned way is up to 50
397+
// nanoseconds faster per run than ESM destructuring syntax.
398+
const capture = listener.capture;
399+
400+
// Handle only the events appropriate to the phase. Global events
401+
// (a NativeScript-only concept) are allowed to be handled
402+
// regardless of phase, for backwards-compatibility.
403+
if (!isGlobal && ((phase === DOMEvent.CAPTURING_PHASE && !capture) || (phase === DOMEvent.BUBBLING_PHASE && capture))) {
404+
continue;
405+
}
406+
396407
// The event listener may have been removed since we took a copy of
397408
// the array, so bail out if so.
398409
//
@@ -410,17 +421,6 @@ export class DOMEvent implements Event {
410421
continue;
411422
}
412423

413-
// Assigning variables this old-fashioned way is up to 50
414-
// nanoseconds faster per run than ESM destructuring syntax.
415-
const capture = listener.capture;
416-
417-
// Handle only the events appropriate to the phase. Global events
418-
// (a NativeScript-only concept) are allowed to be handled
419-
// regardless of phase, for backwards-compatibility.
420-
if (!isGlobal && ((phase === DOMEvent.CAPTURING_PHASE && !capture) || (phase === DOMEvent.BUBBLING_PHASE && capture))) {
421-
continue;
422-
}
423-
424424
const callback = listener.callback;
425425
const thisArg = listener.thisArg;
426426

0 commit comments

Comments
 (0)
0