Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validate({ value } : { value : CrossDomainWindowType | ProxyWindow }) {
if (!isWindow(value) && !ProxyWindow.isProxyWindow(value)) {
throw new Error(`Expected Window or ProxyWindow`);
}
if (isWindow(value)) {
// $FlowFixMe
if (isWindowClosed(value)) {
throw new Error(`Window is closed`);
}
// $FlowFixMe
if (!isSameDomain(value)) {
throw new Error(`Window is not same domain`);
}
}
},
decorate({ value } : { value : CrossDomainWindowType | ProxyWindow }) : ProxyWindow {
validate({ value } : { value : CrossDomainWindowType | ProxyWindow }) {
if (!isWindow(value) && !ProxyWindow.isProxyWindow(value)) {
throw new Error(`Expected Window or ProxyWindow`);
}
if (isWindow(value)) {
// $FlowFixMe
if (isWindowClosed(value)) {
throw new Error(`Window is closed`);
}
// $FlowFixMe
if (!isSameDomain(value)) {
throw new Error(`Window is not same domain`);
}
}
},
decorate({ value } : { value : CrossDomainWindowType | ProxyWindow }) : ProxyWindow {
static isProxyWindow(obj : CrossDomainWindowType | ProxyWindow) : boolean {
// $FlowFixMe
return Boolean(obj && !isWindow(obj) && obj.isProxyWindow);
}
validate: function validate(val) {
if (!isWindow(val) && !ProxyWindow.isProxyWindow(val)) {
throw new Error('Expected Window or ProxyWindow');
}
},
decorate: function decorate(val) {
return ZalgoPromise.try(() => {
if (!isWindow(target)) {
throw new Error(`Must pass window to renderTo`);
}
return this.getDefaultContext(context, props);
}).then(finalContext => {
container = this.getDefaultContainer(finalContext, container);
[ TYPE.OBJECT ]: (val : CrossDomainWindowType) : Object | SerializedWindow => {
return (isWindow(val) || ProxyWindow.isProxyWindow(val)) ? serializeWindow(destination, domain, val, { on, send }) : val;
}
});