mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix: move cheaper check in front
This commit is contained in:
@@ -393,6 +393,17 @@ export class DOMEvent implements Event {
|
|||||||
for (let i = this.listenersLazyCopy.length - 1; i >= 0; i--) {
|
for (let i = this.listenersLazyCopy.length - 1; i >= 0; i--) {
|
||||||
const listener = this.listenersLazyCopy[i];
|
const listener = this.listenersLazyCopy[i];
|
||||||
|
|
||||||
|
// Assigning variables this old-fashioned way is up to 50
|
||||||
|
// nanoseconds faster per run than ESM destructuring syntax.
|
||||||
|
const capture = listener.capture;
|
||||||
|
|
||||||
|
// Handle only the events appropriate to the phase. Global events
|
||||||
|
// (a NativeScript-only concept) are allowed to be handled
|
||||||
|
// regardless of phase, for backwards-compatibility.
|
||||||
|
if (!isGlobal && ((phase === DOMEvent.CAPTURING_PHASE && !capture) || (phase === DOMEvent.BUBBLING_PHASE && capture))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// The event listener may have been removed since we took a copy of
|
// The event listener may have been removed since we took a copy of
|
||||||
// the array, so bail out if so.
|
// the array, so bail out if so.
|
||||||
//
|
//
|
||||||
@@ -410,17 +421,6 @@ export class DOMEvent implements Event {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assigning variables this old-fashioned way is up to 50
|
|
||||||
// nanoseconds faster per run than ESM destructuring syntax.
|
|
||||||
const capture = listener.capture;
|
|
||||||
|
|
||||||
// Handle only the events appropriate to the phase. Global events
|
|
||||||
// (a NativeScript-only concept) are allowed to be handled
|
|
||||||
// regardless of phase, for backwards-compatibility.
|
|
||||||
if (!isGlobal && ((phase === DOMEvent.CAPTURING_PHASE && !capture) || (phase === DOMEvent.BUBBLING_PHASE && capture))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const callback = listener.callback;
|
const callback = listener.callback;
|
||||||
const thisArg = listener.thisArg;
|
const thisArg = listener.thisArg;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user