Skip to content

Commit

Permalink
capricorn86#1092@patch: Simplifies InputEvent.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrotoff committed Sep 24, 2023
1 parent 52abaff commit fb67c3d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/happy-dom/src/event/events/InputEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@ import IInputEventInit from './IInputEventInit.js';
*
*/
export default class InputEvent extends UIEvent {
public readonly data: string = '';
public readonly dataTransfer: DataTransfer = null;
public readonly inputType: string = '';
public readonly isComposing: boolean = false;
public readonly data: string;
public readonly dataTransfer: DataTransfer;
public readonly inputType: string;
public readonly isComposing: boolean;

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

if (eventInit) {
this.data = eventInit.data || '';
this.dataTransfer = eventInit.dataTransfer || null;
this.inputType = eventInit.inputType || '';
this.isComposing = eventInit.isComposing || false;
}
this.data = eventInit.data ?? '';
this.dataTransfer = eventInit.dataTransfer ?? null;
this.inputType = eventInit.inputType ?? '';
this.isComposing = eventInit.isComposing ?? false;
}
}

0 comments on commit fb67c3d

Please sign in to comment.