Question

I've implement the Magento PayPal Captcha module and everything is working great except for IE11. When I pass the captcha and click Place Order on the billing step I get the following error in the browser: SCRIPT65535: Argument not optional and links to a minified/bundled file.

After un-bundling my js (php bin/magento config:set dev/js/enable_js_bundling 1) I see that the error is coming from the list-mixin.min.js file. When I search the codebase for list-mixin, I get the following file: vendor/magento/module-paypal-captcha/view/frontend/web/js/view/payment/list-mixin.js. This file is declaring a clearTimeout function to override the window.clearTimeout() function. However, there is no parameter for this function. If I throw a junk parameter into this file, the console error goes away, but I can't proceed to the order confirmation step. It just spins and I stay on that page - No console errors or log entries.

Based on some googling, it looks as though most browsers handle the lack of a parameter in clearTimeout() function, but IE11 does not. The parameter is required and is the ID value of the timer returned by the setTimeout() method.

TLDR:

  1. How do I determine what setTimeout() call is referenced in a clearTimeout() call so I can pass the correct parameter?
  2. Has anyone else come across this issue on Magento2?

Thanks!

Was it helpful?

Solution

We just implemented the Paypal recaptcha workflow in Magento, and were affected by the same error in IE11. Your post actually helped me identify the error in list-mixin.js, so thank you for that. In return I will share what I did to fix it.

As you pointed out, that file is overriding the built-in window clearTimeout function. That function normally takes a parameter timeoutID. So, I simply added that parameter to the overridden version, and passed it through to the other call, and then everything worked.

The new implementation looks like this, hope it works for you as well:

/**
 * Overrides default window.clearTimeout() to catch errors from iframe and reload Captcha.
 */
clearTimeout: function (timeoutID) {
    var captcha = captchaList.getCaptchaByFormId(this.formId);

    if (captcha !== null) {
        captcha.refresh();
    }
    clearTimeout(timeoutID);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top