Skip to content

Commit

Permalink
capricorn86#1092@patch: Simplifies Event.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrotoff committed Sep 30, 2023
1 parent 6e6acd2 commit d7e6620
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/happy-dom/src/event/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import IDocument from '../nodes/document/IDocument.js';
* Event.
*/
export default class Event {
public composed = false;
public bubbles = false;
public cancelable = false;
public composed: boolean;
public bubbles: boolean;
public cancelable: boolean;
public defaultPrevented = false;
public eventPhase: EventPhaseEnum = EventPhaseEnum.none;
public _immediatePropagationStopped = false;
public _propagationStopped = false;
public _target: IEventTarget = null;
public _currentTarget: IEventTarget = null;
public timeStamp: number = performance.now();
public type: string = null;
public type: string;
public _isInPassiveEventListener = false;
public NONE = EventPhaseEnum.none;
public CAPTURING_PHASE = EventPhaseEnum.capturing;
Expand All @@ -35,14 +35,12 @@ export default class Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IEventInit = null) {
constructor(type: string, eventInit: IEventInit = {}) {
this.type = type;

if (eventInit) {
this.bubbles = eventInit.bubbles || false;
this.cancelable = eventInit.cancelable || false;
this.composed = eventInit.composed || false;
}
this.bubbles = eventInit.bubbles ?? false;
this.cancelable = eventInit.cancelable ?? false;
this.composed = eventInit.composed ?? false;
}

/**
Expand Down

0 comments on commit d7e6620

Please sign in to comment.