Skip to content

Commit

Permalink
capricorn86#1092@patch: Switch back to eventInit = null instead of {}.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrotoff committed Sep 30, 2023
1 parent a09244e commit 40e01dc
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 92 deletions.
8 changes: 4 additions & 4 deletions packages/happy-dom/src/event/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export default class Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IEventInit = {}) {
constructor(type: string, eventInit: IEventInit | null = null) {
this.type = type;

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
6 changes: 3 additions & 3 deletions packages/happy-dom/src/event/UIEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export default class UIEvent extends Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IUIEventInit = {}) {
constructor(type: string, eventInit: IUIEventInit | null = null) {
super(type, eventInit);

this.detail = eventInit.detail ?? 0;
this.view = eventInit.view ?? null;
this.detail = eventInit?.detail ?? 0;
this.view = eventInit?.view ?? null;
}
}
8 changes: 4 additions & 4 deletions packages/happy-dom/src/event/events/AnimationEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export default class AnimationEvent extends Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IAnimationEventInit = {}) {
constructor(type: string, eventInit: IAnimationEventInit | null = null) {
super(type, eventInit);

this.animationName = eventInit.animationName ?? '';
this.elapsedTime = eventInit.elapsedTime ?? 0;
this.pseudoElement = eventInit.pseudoElement ?? '';
this.animationName = eventInit?.animationName ?? '';
this.elapsedTime = eventInit?.elapsedTime ?? 0;
this.pseudoElement = eventInit?.pseudoElement ?? '';
}
}
4 changes: 2 additions & 2 deletions packages/happy-dom/src/event/events/CustomEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export default class CustomEvent extends Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: ICustomEventInit = {}) {
constructor(type: string, eventInit: ICustomEventInit | null = null) {
super(type, eventInit);

this.detail = eventInit.detail ?? null;
this.detail = eventInit?.detail ?? null;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions packages/happy-dom/src/event/events/ErrorEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export default class ErrorEvent extends UIEvent {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IErrorEventInit = {}) {
constructor(type: string, eventInit: IErrorEventInit | null = null) {
super(type, eventInit);

this.message = eventInit.message ?? '';
this.filename = eventInit.filename ?? '';
this.lineno = eventInit.lineno ?? 0;
this.colno = eventInit.colno ?? 0;
this.error = eventInit.error ?? null;
this.message = eventInit?.message ?? '';
this.filename = eventInit?.filename ?? '';
this.lineno = eventInit?.lineno ?? 0;
this.colno = eventInit?.colno ?? 0;
this.error = eventInit?.error ?? null;
}
}
4 changes: 2 additions & 2 deletions packages/happy-dom/src/event/events/FocusEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export default class FocusEvent extends UIEvent {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IFocusEventInit = {}) {
constructor(type: string, eventInit: IFocusEventInit | null = null) {
super(type, eventInit);

this.relatedTarget = eventInit.relatedTarget ?? null;
this.relatedTarget = eventInit?.relatedTarget ?? null;
}
}
10 changes: 5 additions & 5 deletions packages/happy-dom/src/event/events/InputEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export default class InputEvent extends UIEvent {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IInputEventInit = {}) {
constructor(type: string, eventInit: IInputEventInit | null = null) {
super(type, 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;
}
}
20 changes: 10 additions & 10 deletions packages/happy-dom/src/event/events/KeyboardEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ export default class KeyboardEvent extends UIEvent {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IKeyboardEventInit = {}) {
constructor(type: string, eventInit: IKeyboardEventInit | null = null) {
super(type, eventInit);

this.altKey = eventInit.altKey ?? false;
this.code = eventInit.code ?? '';
this.ctrlKey = eventInit.ctrlKey ?? false;
this.isComposing = eventInit.isComposing ?? false;
this.key = eventInit.key ?? '';
this.location = eventInit.location ?? 0;
this.metaKey = eventInit.metaKey ?? false;
this.repeat = eventInit.repeat ?? false;
this.shiftKey = eventInit.shiftKey ?? false;
this.altKey = eventInit?.altKey ?? false;
this.code = eventInit?.code ?? '';
this.ctrlKey = eventInit?.ctrlKey ?? false;
this.isComposing = eventInit?.isComposing ?? false;
this.key = eventInit?.key ?? '';
this.location = eventInit?.location ?? 0;
this.metaKey = eventInit?.metaKey ?? false;
this.repeat = eventInit?.repeat ?? false;
this.shiftKey = eventInit?.shiftKey ?? false;
}
}
6 changes: 3 additions & 3 deletions packages/happy-dom/src/event/events/MediaQueryListEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export default class MediaQueryListEvent extends Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IMediaQueryListInit = {}) {
constructor(type: string, eventInit: IMediaQueryListInit | null = null) {
super(type, eventInit);

this.matches = eventInit.matches ?? false;
this.media = eventInit.media ?? '';
this.matches = eventInit?.matches ?? false;
this.media = eventInit?.media ?? '';
}
}
12 changes: 6 additions & 6 deletions packages/happy-dom/src/event/events/MessageEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export default class MessageEvent extends Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IMessageEventInit = {}) {
constructor(type: string, eventInit: IMessageEventInit | null = null) {
super(type, eventInit);

this.data = eventInit.data ?? null;
this.origin = eventInit.origin ?? '';
this.lastEventId = eventInit.lastEventId ?? '';
this.source = eventInit.source ?? null;
this.ports = eventInit.ports ?? [];
this.data = eventInit?.data ?? null;
this.origin = eventInit?.origin ?? '';
this.lastEventId = eventInit?.lastEventId ?? '';
this.source = eventInit?.source ?? null;
this.ports = eventInit?.ports ?? [];
}
}
30 changes: 15 additions & 15 deletions packages/happy-dom/src/event/events/MouseEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ export default class MouseEvent extends UIEvent {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IMouseEventInit = {}) {
constructor(type: string, eventInit: IMouseEventInit | null = null) {
super(type, eventInit);

this.altKey = eventInit.altKey ?? false;
this.button = eventInit.button ?? 0;
this.buttons = eventInit.buttons ?? 0;
this.clientX = eventInit.clientX ?? 0;
this.clientY = eventInit.clientY ?? 0;
this.ctrlKey = eventInit.ctrlKey ?? false;
this.metaKey = eventInit.metaKey ?? false;
this.movementX = eventInit.movementX ?? 0;
this.movementY = eventInit.movementY ?? 0;
this.region = eventInit.region ?? '';
this.relatedTarget = eventInit.relatedTarget ?? null;
this.screenX = eventInit.screenX ?? 0;
this.screenY = eventInit.screenY ?? 0;
this.shiftKey = eventInit.shiftKey ?? false;
this.altKey = eventInit?.altKey ?? false;
this.button = eventInit?.button ?? 0;
this.buttons = eventInit?.buttons ?? 0;
this.clientX = eventInit?.clientX ?? 0;
this.clientY = eventInit?.clientY ?? 0;
this.ctrlKey = eventInit?.ctrlKey ?? false;
this.metaKey = eventInit?.metaKey ?? false;
this.movementX = eventInit?.movementX ?? 0;
this.movementY = eventInit?.movementY ?? 0;
this.region = eventInit?.region ?? '';
this.relatedTarget = eventInit?.relatedTarget ?? null;
this.screenX = eventInit?.screenX ?? 0;
this.screenY = eventInit?.screenY ?? 0;
this.shiftKey = eventInit?.shiftKey ?? false;
}
}
30 changes: 15 additions & 15 deletions packages/happy-dom/src/event/events/PointerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ export default class PointerEvent extends MouseEvent {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IPointerEventInit = {}) {
constructor(type: string, eventInit: IPointerEventInit | null = null) {
super(type, eventInit);

this.pointerId = eventInit.pointerId ?? 0;
this.width = eventInit.width ?? 1;
this.height = eventInit.height ?? 1;
this.pressure = eventInit.pressure ?? 0;
this.tangentialPressure = eventInit.tangentialPressure ?? 0;
this.tiltX = eventInit.tiltX ?? 0;
this.tiltY = eventInit.tiltY ?? 0;
this.twist = eventInit.twist ?? 0;
this.altitudeAngle = eventInit.altitudeAngle ?? 0;
this.azimuthAngle = eventInit.azimuthAngle ?? 0;
this.pointerType = eventInit.pointerType ?? '';
this.isPrimary = eventInit.isPrimary ?? false;
this.coalescedEvents = eventInit.coalescedEvents ?? [];
this.predictedEvents = eventInit.predictedEvents ?? [];
this.pointerId = eventInit?.pointerId ?? 0;
this.width = eventInit?.width ?? 1;
this.height = eventInit?.height ?? 1;
this.pressure = eventInit?.pressure ?? 0;
this.tangentialPressure = eventInit?.tangentialPressure ?? 0;
this.tiltX = eventInit?.tiltX ?? 0;
this.tiltY = eventInit?.tiltY ?? 0;
this.twist = eventInit?.twist ?? 0;
this.altitudeAngle = eventInit?.altitudeAngle ?? 0;
this.azimuthAngle = eventInit?.azimuthAngle ?? 0;
this.pointerType = eventInit?.pointerType ?? '';
this.isPrimary = eventInit?.isPrimary ?? false;
this.coalescedEvents = eventInit?.coalescedEvents ?? [];
this.predictedEvents = eventInit?.predictedEvents ?? [];
}

public getCoalescedEvents = (): PointerEvent[] => this.coalescedEvents;
Expand Down
8 changes: 4 additions & 4 deletions packages/happy-dom/src/event/events/ProgressEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export default class ProgressEvent extends Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IProgressEventInit = {}) {
constructor(type: string, eventInit: IProgressEventInit | null = null) {
super(type);

this.lengthComputable = eventInit.lengthComputable ?? false;
this.loaded = eventInit.loaded ?? 0;
this.total = eventInit.total ?? 0;
this.lengthComputable = eventInit?.lengthComputable ?? false;
this.loaded = eventInit?.loaded ?? 0;
this.total = eventInit?.total ?? 0;
}
}
12 changes: 6 additions & 6 deletions packages/happy-dom/src/event/events/StorageEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export default class StorageEvent extends Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IStorageEventInit = {}) {
constructor(type: string, eventInit: IStorageEventInit | null = null) {
super(type);

this.key = eventInit.key ?? null;
this.oldValue = eventInit.oldValue ?? null;
this.newValue = eventInit.newValue ?? null;
this.url = eventInit.url ?? '';
this.storageArea = eventInit.storageArea ?? null;
this.key = eventInit?.key ?? null;
this.oldValue = eventInit?.oldValue ?? null;
this.newValue = eventInit?.newValue ?? null;
this.url = eventInit?.url ?? '';
this.storageArea = eventInit?.storageArea ?? null;
}
}
4 changes: 2 additions & 2 deletions packages/happy-dom/src/event/events/SubmitEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export default class SubmitEvent extends Event {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: ISubmitEventInit = {}) {
constructor(type: string, eventInit: ISubmitEventInit | null = null) {
super(type, eventInit);

this.submitter = eventInit.submitter ?? null;
this.submitter = eventInit?.submitter ?? null;
}
}
10 changes: 5 additions & 5 deletions packages/happy-dom/src/event/events/WheelEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export default class WheelEvent extends UIEvent {
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IWheelEventInit = {}) {
constructor(type: string, eventInit: IWheelEventInit | null = null) {
super(type, eventInit);

this.deltaX = eventInit.deltaX ?? 0;
this.deltaY = eventInit.deltaY ?? 0;
this.deltaZ = eventInit.deltaZ ?? 0;
this.deltaMode = eventInit.deltaMode ?? 0;
this.deltaX = eventInit?.deltaX ?? 0;
this.deltaY = eventInit?.deltaY ?? 0;
this.deltaZ = eventInit?.deltaZ ?? 0;
this.deltaMode = eventInit?.deltaMode ?? 0;
}
}

0 comments on commit 40e01dc

Please sign in to comment.