refactor: use Map for windowProxies in window-setup.ts (#20600)

This commit is contained in:
Milan Burda 2019-10-17 15:07:27 +02:00 committed by Alexey Kuzmin
parent e06b0aa73b
commit b29f0b9348

View file

@ -28,19 +28,19 @@ const toString = (value: any) => {
return value != null ? `${value}` : value return value != null ? `${value}` : value
} }
const windowProxies: Record<number, BrowserWindowProxy> = {} const windowProxies = new Map<number, BrowserWindowProxy>()
const getOrCreateProxy = (guestId: number) => { const getOrCreateProxy = (guestId: number) => {
let proxy = windowProxies[guestId] let proxy = windowProxies.get(guestId)
if (proxy == null) { if (proxy == null) {
proxy = new BrowserWindowProxy(guestId) proxy = new BrowserWindowProxy(guestId)
windowProxies[guestId] = proxy windowProxies.set(guestId, proxy)
} }
return proxy return proxy
} }
const removeProxy = (guestId: number) => { const removeProxy = (guestId: number) => {
delete windowProxies[guestId] windowProxies.delete(guestId)
} }
type LocationProperties = 'hash' | 'href' | 'host' | 'hostname' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' type LocationProperties = 'hash' | 'href' | 'host' | 'hostname' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search'