Skip to content

Commit

Permalink
capricorn86#1092@patch: Simplifies ProgressEvent.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrotoff committed Sep 30, 2023
1 parent 2f81725 commit 4714f21
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/happy-dom/src/event/events/ProgressEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ import IProgressEventInit from './IProgressEventInit.js';
*
*/
export default class ProgressEvent extends Event {
public readonly lengthComputable: boolean = false;
public readonly loaded: number = 0;
public readonly total: number = 0;
public readonly lengthComputable: boolean;
public readonly loaded: number;
public readonly total: number;

/**
* Constructor.
*
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IProgressEventInit = null) {
constructor(type: string, eventInit: IProgressEventInit = {}) {
super(type);

if (eventInit) {
this.lengthComputable = eventInit.lengthComputable || false;
this.loaded = eventInit.loaded !== undefined ? eventInit.loaded : 0;
this.total = eventInit.total !== undefined ? eventInit.total : 0;
}
this.lengthComputable = eventInit.lengthComputable ?? false;
this.loaded = eventInit.loaded ?? 0;
this.total = eventInit.total ?? 0;
}
}

0 comments on commit 4714f21

Please sign in to comment.