Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (domain === getDomain(window)) {
const global = getGlobal(window);
global.windows = global.windows || {};
global.windows[uid] = window;
this.clean.register(() => {
delete global.windows[uid];
});
return { type: WINDOW_REFERENCES.GLOBAL, uid };
}
if (context === CONTEXT.POPUP) {
return { type: WINDOW_REFERENCES.OPENER };
}
return { type: WINDOW_REFERENCES.PARENT, distance: getDistanceFromTop(window) };
}
return { type: WINDOW_REFERENCES.GLOBAL, uid };
}
if (target !== window) {
throw new Error(`Can not currently create window reference for different target with a different domain`);
}
if (context === CONTEXT.POPUP) {
return { type: WINDOW_REFERENCES.OPENER };
}
if (isTop(window)) {
return { type: WINDOW_REFERENCES.TOP };
}
return { type: WINDOW_REFERENCES.PARENT, distance: getDistanceFromTop(window) };
}
return { type: WINDOW_REFERENCES.GLOBAL, uid: uid };
}
if (target !== window) {
throw new Error('Can not currently create window reference for different target with a different domain');
}
if (context === CONTEXT.POPUP) {
return { type: WINDOW_REFERENCES.OPENER };
}
if (isTop(window)) {
return { type: WINDOW_REFERENCES.TOP };
}
return { type: WINDOW_REFERENCES.PARENT, distance: getDistanceFromTop(window) };
};