skip to Main Content

Magento 1 use prototypejs, this library overrides Array.form line 1081 in its 1.7 version:

Array.from = $A;

This cause the following JavaScript error in the Console:

This site overrides Array.from() with an implementation that doesn’t
support iterables, which could cause Google Maps JavaScript API v3 to
not work correctly.

Editing this core library does not seem reasonable, how do Magento developers deal with this conflict ?

2

Answers


  1. I think I have found a solution.
    Replace the line array.from($A)
    by this :

    function isIterable(obj) {
      // checks for null and undefined
      if (obj == null) {
        return false;
      }
      return typeof obj[Symbol.iterator] === 'function';
    }
    if (isIterable($A)) {
      Array.from = $A;
    }
    Login or Signup to reply.
  2. A similar issue has been reported in our Public Issue Tracker and already been addressed by our Engineering team. As per latest comment:

    We’ve just submitted an update for this. The check is now more explicit and will cover your use case: Array.from(new Set([42]))[0] !== 42 … warn

    This will be available in an upcoming weekly release

    Public Issue Tracker is a tool used internally at Google to track bugs and feature requests during product development. It is available outside of Google for use by external public and partner users who need to collaborate with Google teams on specific projects. You can learn more here https://developers.google.com/issue-tracker/.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search