Skip to content

Commit

Permalink
https://html.spec.whatwg.org/multipage/webstorage.html#the-storageeve…
Browse files Browse the repository at this point in the history
…nt-interface.
  • Loading branch information
tkrotoff committed Sep 24, 2023
1 parent 0e579ce commit 413d791
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion packages/happy-dom/src/event/events/IStorageEventInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import Storage from '../../storage/Storage.js';

export default interface IStorageEventInit extends IEventInit {
key?: string;
newValue?: string;
oldValue?: string;
newValue?: string;
url?: string;
storageArea?: Storage;
}
22 changes: 11 additions & 11 deletions packages/happy-dom/src/event/events/StorageEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import Storage from '../../storage/Storage.js';
*
*/
export default class StorageEvent extends Event {
public readonly key: string = null;
public readonly newValue: string = null;
public readonly oldValue: string = null;
public readonly storageArea: Storage = null;
public readonly key: string | null;
public readonly oldValue: string | null;
public readonly newValue: string | null;
public readonly url: string;
public readonly storageArea: Storage | null;

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

if (eventInit) {
this.key = eventInit.key !== undefined ? eventInit.key : null;
this.newValue = eventInit.newValue !== undefined ? eventInit.newValue : null;
this.oldValue = eventInit.oldValue !== undefined ? eventInit.oldValue : null;
this.storageArea = eventInit.storageArea !== undefined ? 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;
}
}

0 comments on commit 413d791

Please sign in to comment.