Magento2: Vertex_AddressValidation breaks checkout on IE11 due to the use of Object.entries

Created on 16 Jun 2020  路  14Comments  路  Source: magento/magento2

Preconditions (*)

  1. M2.3.5-p1 (untested on other versions).
  2. Vertex_AddressValidation enabled.
  3. IE11 as the browser.

Steps to reproduce (*)

  1. Add an item into the cart.
  2. Navigate to checkout.

Expected result (*)

  1. Checkout works without errors in the console.

Actual result (*)

  1. Error in the console "Object doesn't support property or method 'entries'".

Notes

This is due to the usage of Object.entries in vertex/module-address-validation/view/frontend/web/js/view/validation-message.js which is not supported on IE11. As IE11 regrettably remains a supported browser, and the Vertex module is bundled with Magento, this probably should be fixed.

Severity S1 due to the problem affecting checkout.


  • [x] Severity: S1 _- Affects critical data or functionality and forces users to employ a workaround._
Bundled Extension Checkout Clear Description Confirmed Format is valid done Reported on 2.3.5-p1 Reproduced on 2.3.x

Most helpful comment

I had the same issue and was able to get around it using a polyfill.
app/code/Vendor/Module/view/frontend/web/js/ie11polyfill.js

define([],function(){
    if (!Object.entries)
        Object.entries = function( obj ){
            var ownProps = Object.keys( obj ),
                i = ownProps.length,
                resArray = new Array(i); // preallocate the Array
            while (i--)
                resArray[i] = [ownProps[i], obj[ownProps[i]]];

            return resArray;
        };

    return Object.entries;
});

Then add it as a dependency for the validation js that's having issues.
in requirejs-config.js

var config = {
    shim: {
        'Vertex_AddressValidation/js/view/validation-message': {
            deps: ['Vendor_Module/js/ie11polyfill']
        }
    }
};

Hope this helps anyone who's having the same issue.

All 14 comments

Hi @mattijv. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


Hi @swathishs. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

@magento give me 2.3.5-p1 instance

Hi @swathishs. Thank you for your request. I'm working on Magento 2.3.5-p1 instance for you

Hi @swathishs, here is your Magento instance.
Admin access: https://i-28742-2-3-5-p1.instances.magento-community.engineering/admin_e87c
Login: 9c10c339 Password: 1092453e9202
Instance will be terminated in up to 3 hours.

@magento give me 2.3.5-p1 instance with vertex setting

Hi @swathishs. Thank you for your request. I'm working on Magento 2.3.5-p1 instance for you

I had the same issue and was able to get around it using a polyfill.
app/code/Vendor/Module/view/frontend/web/js/ie11polyfill.js

define([],function(){
    if (!Object.entries)
        Object.entries = function( obj ){
            var ownProps = Object.keys( obj ),
                i = ownProps.length,
                resArray = new Array(i); // preallocate the Array
            while (i--)
                resArray[i] = [ownProps[i], obj[ownProps[i]]];

            return resArray;
        };

    return Object.entries;
});

Then add it as a dependency for the validation js that's having issues.
in requirejs-config.js

var config = {
    shim: {
        'Vertex_AddressValidation/js/view/validation-message': {
            deps: ['Vendor_Module/js/ie11polyfill']
        }
    }
};

Hope this helps anyone who's having the same issue.

@brigitschroeder Great workaround, thanks for posting! Luckily for me, I could just disable the Vertex modules and not worry about it.

An internal ticket, BUNDLE-2583 exists for this issue. If needed, you can use the patch here: BUNDLE-2583.patch

@navarr regarding the patch you provided, will let actually work in ie11? 馃 I think it should be var instead.

+            for (let key in object) {}

@navarr The patch you posted is not correct and excessive. After analyzing the code, it would be sufficient to replace all Object.entries with Object.keys because we are only trying to figure out if said object is empty or not so the outcome would be the same.

Hi @krzksz. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

The Issue has been fixed and included in the 2.3.6 Magento release.

Was this page helpful?
0 / 5 - 0 ratings