mirror of
https://github.com/vector-im/element-call.git
synced 2026-05-01 09:54:37 +00:00
address review comments
This commit is contained in:
@@ -51,3 +51,53 @@ window.matchMedia = global.matchMedia = (): MediaQueryList =>
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
}) as Partial<MediaQueryList> as MediaQueryList;
|
||||
|
||||
const storage: Record<string, string> = {};
|
||||
const localStoragePolyfill = {
|
||||
getItem(key: string) {
|
||||
return Object.prototype.hasOwnProperty.call(storage, key)
|
||||
? storage[key]
|
||||
: null;
|
||||
},
|
||||
setItem(key: string, value: string) {
|
||||
storage[key] = String(value);
|
||||
},
|
||||
removeItem(key: string) {
|
||||
delete storage[key];
|
||||
},
|
||||
clear() {
|
||||
for (const key in storage) {
|
||||
delete storage[key];
|
||||
}
|
||||
},
|
||||
key(index: number) {
|
||||
const keys = Object.keys(storage);
|
||||
return keys[index] ?? null;
|
||||
},
|
||||
get length() {
|
||||
return Object.keys(storage).length;
|
||||
},
|
||||
} as unknown as Storage;
|
||||
|
||||
if (
|
||||
typeof globalThis.localStorage === "undefined" ||
|
||||
typeof globalThis.localStorage.clear !== "function"
|
||||
) {
|
||||
Object.defineProperty(globalThis, "localStorage", {
|
||||
value: localStoragePolyfill,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
typeof window !== "undefined" &&
|
||||
(typeof window.localStorage === "undefined" ||
|
||||
typeof window.localStorage.clear !== "function")
|
||||
) {
|
||||
Object.defineProperty(window, "localStorage", {
|
||||
value: localStoragePolyfill,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user