Skip to content

Commit 253d313

Browse files
committed
chore: use static constants for readability (no perf difference)
1 parent 0513789 commit 253d313

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
@@ -280,7 +280,7 @@ export class DOMEvent implements Event {
280280
private resetForRedispatch() {
281281
this.currentTarget = null;
282282
this.target = null;
283-
this.eventPhase = this.NONE;
283+
this.eventPhase = DOMEvent.NONE;
284284
this.propagationState = EventPropagationState.resume;
285285
this.listenersLive = emptyArray;
286286
this.listenersLazyCopy = emptyArray;
@@ -291,10 +291,10 @@ export class DOMEvent implements Event {
291291
* method was not invoked, and false otherwise.
292292
*/
293293
dispatchTo({ target, data, getGlobalEventHandlersPreHandling, getGlobalEventHandlersPostHandling }: { target: Observable; data: EventData; getGlobalEventHandlersPreHandling?: () => MutationSensitiveArray<ListenerEntry>; getGlobalEventHandlersPostHandling?: () => MutationSensitiveArray<ListenerEntry> }): boolean {
294-
if (this.eventPhase !== this.NONE) {
294+
if (this.eventPhase !== DOMEvent.NONE) {
295295
throw new Error('Tried to dispatch a dispatching event');
296296
}
297-
this.eventPhase = this.CAPTURING_PHASE;
297+
this.eventPhase = DOMEvent.CAPTURING_PHASE;
298298
this.target = target;
299299
this.defaultPrevented = false;
300300

@@ -332,7 +332,7 @@ export class DOMEvent implements Event {
332332
// possible.
333333

334334
this.listenersLazyCopy = this.listenersLive = getGlobalEventHandlersPreHandling?.() || emptyArray;
335-
this.handleEvent(data, true, this.CAPTURING_PHASE, removeGlobalEventListener, target.constructor);
335+
this.handleEvent(data, true, DOMEvent.CAPTURING_PHASE, removeGlobalEventListener, target.constructor);
336336

337337
const eventPath = this.getEventPath(target, 'capture');
338338

@@ -342,10 +342,10 @@ export class DOMEvent implements Event {
342342
for (let i = 0; i < eventPath.length; i++) {
343343
const currentTarget = eventPath[i];
344344
this.currentTarget = currentTarget;
345-
this.eventPhase = this.target === this.currentTarget ? this.AT_TARGET : this.CAPTURING_PHASE;
345+
this.eventPhase = this.target === this.currentTarget ? DOMEvent.AT_TARGET : DOMEvent.CAPTURING_PHASE;
346346

347347
this.listenersLazyCopy = this.listenersLive = currentTarget.getEventList(this.type) || emptyArray;
348-
this.handleEvent(data, false, this.CAPTURING_PHASE, currentTarget.removeEventListener, currentTarget);
348+
this.handleEvent(data, false, DOMEvent.CAPTURING_PHASE, currentTarget.removeEventListener, currentTarget);
349349

350350
if (this.propagationState !== EventPropagationState.resume) {
351351
this.resetForRedispatch();
@@ -357,10 +357,10 @@ export class DOMEvent implements Event {
357357
// It's correct to dispatch the event to the target during both phases.
358358
for (let i = eventPath.length - 1; i >= 0; i--) {
359359
const currentTarget = eventPath[i];
360-
this.eventPhase = this.target === this.currentTarget ? this.AT_TARGET : this.BUBBLING_PHASE;
360+
this.eventPhase = this.target === this.currentTarget ? DOMEvent.AT_TARGET : DOMEvent.BUBBLING_PHASE;
361361

362362
this.listenersLazyCopy = this.listenersLive = currentTarget.getEventList(this.type) || emptyArray;
363-
this.handleEvent(data, false, this.BUBBLING_PHASE, currentTarget.removeEventListener, currentTarget);
363+
this.handleEvent(data, false, DOMEvent.BUBBLING_PHASE, currentTarget.removeEventListener, currentTarget);
364364

365365
if (this.propagationState !== EventPropagationState.resume) {
366366
this.resetForRedispatch();
@@ -377,11 +377,11 @@ export class DOMEvent implements Event {
377377

378378
// Restore event phase in case it changed to AT_TARGET during
379379
// this.handleEvent().
380-
this.eventPhase = this.BUBBLING_PHASE;
380+
this.eventPhase = DOMEvent.BUBBLING_PHASE;
381381
}
382382

383383
this.listenersLazyCopy = this.listenersLive = getGlobalEventHandlersPostHandling?.() || emptyArray;
384-
this.handleEvent(data, true, this.BUBBLING_PHASE, removeGlobalEventListener, target.constructor);
384+
this.handleEvent(data, true, DOMEvent.BUBBLING_PHASE, removeGlobalEventListener, target.constructor);
385385

386386
this.resetForRedispatch();
387387
return !this.defaultPrevented;
@@ -417,7 +417,7 @@ export class DOMEvent implements Event {
417417
// Handle only the events appropriate to the phase. Global events
418418
// (a NativeScript-only concept) are allowed to be handled
419419
// regardless of phase, for backwards-compatibility.
420-
if (!isGlobal && ((phase === this.CAPTURING_PHASE && !capture) || (phase === this.BUBBLING_PHASE && capture))) {
420+
if (!isGlobal && ((phase === DOMEvent.CAPTURING_PHASE && !capture) || (phase === DOMEvent.BUBBLING_PHASE && capture))) {
421421
continue;
422422
}
423423

0 commit comments

Comments
 (0)