How to use the cross-domain-utils/src.getParent function in cross-domain-utils

To help you get started, we’ve selected a few cross-domain-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paypal / paypal-checkout-components / src / hacks.js View on Github external
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);
            }
github krakenjs / zoid / dist / module / component / child / index.js View on Github external
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];
github paypal / paypal-checkout-components / src / interface / hacks.js View on Github external
/* @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);
            }
github paypal / paypal-smart-payment-buttons / src / payment-flows / checkout.js View on Github external
function getRenderWindow() : Object {
    const top = getTop(window);
    if (canRenderTop && top) {
        return top;
    } else if (getParent()) {
        return getParent();
    } else {
        return window;
    }
}
github krakenjs / post-robot / src / bridge / bridge.js View on Github external
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 {
github paypal / paypal-checkout-components / src / interface / hacks.js View on Github external
patchMethod(Checkout, 'renderTo', ({ args: [ win, props, el ], original, context }) => {

            if (!canRenderTop) {
                win = getParent(window);
            }

            return original.call(context, win, props, el);
        });
    }
github paypal / paypal-checkout-components / src / hacks.js View on Github external
patchMethod(Checkout, 'renderTo', ({ args: [ win, props, el ], original, context }) => {

            if (!canRenderTop) {
                win = getParent(window);
            }

            return original.call(context, win, props, el);
        });
    }
github paypal / paypal-smart-payment-buttons / src / payment-flows / checkout.js View on Github external
function getRenderWindow() : Object {
    const top = getTop(window);
    if (canRenderTop && top) {
        return top;
    } else if (getParent()) {
        return getParent();
    } else {
        return window;
    }
}