Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Error: Request listener already exists for zoid_allow_delegate_foo on domain * for wildcard window[Bug] Bug report #417

Open
emontezumazipco opened this issue Dec 19, 2022 · 1 comment

Comments

@emontezumazipco
Copy link

Hi team.
I am working with zoid on VUE and I am getting this error on the customer site.
this is my code to init te zoid component.

export default create({
  // tag-name for component, used for loading the correct component in the child window, etc.
  tag: 'foo',
  // the full url that will be loaded when the child component is rendered
  url: ({ props }) => {
    return props.url;
  },
  dimensions: {
    height: '960px',
    width: '860px',
  },
  props: {
    url: {
      type: 'string',
      required: true,
    },
    zoidCallback: {
      type: 'function',
      required: false,
    },
    zoidClosed: {
      type: 'function',
      required: false,
    },
    zoidError: {
      type: 'function',
      required: false,
    },
    bridgeUrl: {
      type: 'string',
      required: true,
    },
    forceIframe: {
      type: 'boolean',
      required: false,
    },
    hideOverlay: {
      type: 'boolean',
      required: false,
    },
  },
  // loaded in place of child (popup/iframe) before child is done
  prerenderTemplate: prerenderTemplate,
  // loaded on parent window (merchant site)
  containerTemplate: containerTemplate,
  bridgeUrl: ({ props }) => {
    return props.bridgeUrl;
  },
});

To init the zoid component Ima using this code

function createZoidComponent(configuration: CheckoutConfiguration, checkoutUrl: string) {
  const forceIframe = !!configuration.forceIframe;
  const hideOverlay = !!configuration.hideOverlay;
  const requiresPopup = !configuration.forceIframe && supportsPopups();

 zoidComponent = zoidComponentInit({
    url: checkoutUrl,
    zoidCallback: zoidCallback,
    zoidClosed: zoidClosed,
    zoidError: zoidError,
    bridgeUrl: `${environmentConfiguration.gatewayHost}/virtual/bridge?version=${encodeURIComponent(postRobotVersion)}`,
    forceIframe: forceIframe,
    hideOverlay: hideOverlay,
  });

  const element = 'body';
  zoidComponent.render(element, requiresPopup ? 'popup' : 'iframe').catch(async (e: Error) => {
    if (e?.message?.toLowerCase() !== 'Window closed'.toLowerCase()) {
      logger.error(e);
    } else {
      logger.debug('Window closed while prerender template is active', e);
    }

    await zoidClosed(e.message);
  });

  if (requiresPopup) {
    const $navHelper = document.querySelector('.navhelper');
    if ($navHelper) $navHelper.addEventListener('click', focusCheckout.bind(this));
  }
}

@emontezumazipco
Copy link
Author

Any comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant