Skip to content

Commit

Permalink
capricorn86#1092@patch: Simplifies CustomEvent.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrotoff committed Sep 24, 2023
1 parent 5403721 commit 53fb3b9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/happy-dom/src/event/events/CustomEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ import ICustomEventInit from './ICustomEventInit.js';
*
*/
export default class CustomEvent extends Event {
public detail: object = null;
public detail: object;

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

if (eventInit) {
this.detail = eventInit.detail !== undefined ? eventInit.detail : null;
}
this.detail = eventInit.detail ?? null;
}

/**
Expand Down

0 comments on commit 53fb3b9

Please sign in to comment.