Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Native Array.from is overwritten by $A which is not able to handle all cases used by the native function #338

Copy link
Copy link
@maxwangry

Description

@maxwangry
Issue body actions

In version 1.7.3, the native Array.from is overwritten by $A as below:

function $A(iterable) {
  if (!iterable) return [];
  if ('toArray' in Object(iterable)) return iterable.toArray();
  var length = iterable.length || 0, results = new Array(length);
  while (length--) results[length] = iterable[length];
  return results;
}

Array.from = $A;

From the definition of these two functions:
The Array.from() method creates a new Array instance from an array-like or iterable object.
However, the $A function only accepts an array-like collection (anything with numeric indices).
So $A is not able to handle other iterable objects without numeric indices such as MapIterator.

When $A try to create a new array by reading the iterable.length which does exist in some native iterable objects such as MapIterator, the result will be an array with length 0 returned back.

Hope this will be fixed soon.

Thanks,
Max

lnaravindan, brucemead, mwgamble, rcurrington, devmanda and 8 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.