Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
checkout.openContainer().then(() => {
checkout.event.triggerOnce(CONSTANTS.EVENTS.CLOSE);
checkout.showContainer();
});
// $FlowFixMe
Button.xprops.payment().then(token => {
window.top.location = extendUrl(config.checkoutUrl, { token });
}).catch(err => {
checkout.error(err);
});
};
}
const parent = getParent(window);
const top = getTop(window);
if (top && parent) {
let canRenderTop = (top === parent);
if (!canRenderTop) {
Checkout.canRenderTo(top).then(result => {
canRenderTop = result;
});
patchMethod(Checkout, 'renderTo', ({ args: [ win, props, el ], original, context }) => {
if (!canRenderTop) {
win = getParent(window);
}
var result = void 0;
if (type === WINDOW_REFERENCES.OPENER) {
result = getOpener(window);
} else if (type === WINDOW_REFERENCES.TOP) {
result = getTop(window);
} else if (type === WINDOW_REFERENCES.PARENT) {
// $FlowFixMe
var distance = ref.distance;
if (distance) {
result = getNthParentFromTop(window, distance);
} else {
result = getParent(window);
}
}
if (type === WINDOW_REFERENCES.GLOBAL) {
// $FlowFixMe
var uid = ref.uid;
var ancestor = getAncestor(window);
if (ancestor) {
for (var _i2 = 0, _getAllFramesInWindow2 = getAllFramesInWindow(ancestor), _length2 = _getAllFramesInWindow2 == null ? 0 : _getAllFramesInWindow2.length; _i2 < _length2; _i2++) {
var frame = _getAllFramesInWindow2[_i2];
var global = globalFor(frame);
if (global && global.windows && global.windows[uid]) {
result = global.windows[uid];
/* @flow */
import { getLogger } from 'paypal-braintree-web-client/src';
import { getParent, getTop } from 'cross-domain-utils/src';
import { patchMethod } from 'belter/src';
import { Checkout } from '../checkout';
const parent = getParent(window);
const top = getTop(window);
if (top && parent) {
let canRenderTop = (top === parent);
if (!canRenderTop) {
Checkout.canRenderTo(top).then(result => {
canRenderTop = result;
});
patchMethod(Checkout, 'renderTo', ({ args: [ win, props, el ], original, context }) => {
if (!canRenderTop) {
win = getParent(window);
}
function getRenderWindow() : Object {
const top = getTop(window);
if (canRenderTop && top) {
return top;
} else if (getParent()) {
return getParent();
} else {
return window;
}
}
getGlobal(window).openTunnelToParent = function openTunnelToParent({ name, source, canary, sendMessage } : TunnelWindowDataType) : ZalgoPromise {
const tunnelWindows = globalStore('tunnelWindows');
const parentWindow = getParent(window);
if (!parentWindow) {
throw new Error(`No parent window found to open tunnel to`);
}
const id = addTunnelWindow({ name, source, canary, sendMessage });
return send(parentWindow, MESSAGE_NAME.OPEN_TUNNEL, {
name,
sendMessage() {
const tunnelWindow = tunnelWindows.get(id);
try {
patchMethod(Checkout, 'renderTo', ({ args: [ win, props, el ], original, context }) => {
if (!canRenderTop) {
win = getParent(window);
}
return original.call(context, win, props, el);
});
}
patchMethod(Checkout, 'renderTo', ({ args: [ win, props, el ], original, context }) => {
if (!canRenderTop) {
win = getParent(window);
}
return original.call(context, win, props, el);
});
}
function getRenderWindow() : Object {
const top = getTop(window);
if (canRenderTop && top) {
return top;
} else if (getParent()) {
return getParent();
} else {
return window;
}
}