Angular-cli: Object.entries not supported in IE

Created on 13 Mar 2018  路  9Comments  路  Source: angular/angular-cli

Object.entries should be included in the polyfills for IE support

Versions

Angular CLI: 1.5.0
Node: 8.9.1
OS: darwin x64
Angular: 5.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.7
typescript: 2.4.2
webpack: 3.8.1

Repro steps


If you ever want to use Object.entries you can not

Observed behavior

Object.entries is not supported in IE

Desired behavior

Object.entries should be supported and added to polyfills

Mention any other details that might be useful (optional)

This is the code to be added:

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;
  };

Source: https://stackoverflow.com/questions/42446062/object-doesnt-support-property-or-method-entries

feature

Most helpful comment

Object.entries comes from ES7 =>

import 'core-js/es7/object';

All 9 comments

I believe this is handled by the polyfills defined in the polyfills file. You'll have to uncomment those for IE support in that file. If that does not solve you issue, you could add the definition you have above into that file yourself.

@Brocco I did uncomment the polyfills but still needs a polyfill for Object.entries to be added.

Object.entries comes from ES7 =>

import 'core-js/es7/object';

@wKoza thanks, I also think that this should be added to the polyfills list on: /** IE9, IE10 and IE11 requires all of the following polyfills. **/

Only polyfills required by Angular itself are included in the list. If an application's code needs specific polyfills then they can be added as needed.

Closing as answer in the above comment.

Only polyfills required by Angular itself are included in the list. If an application's code needs specific polyfills then they can be added as needed.

But how can we make those polyfills to be added to es2015-polyfills.js? If those are added to the general polyfills.js it kinda defeats the purpose.

Have solved by adding this to polyfills.js

// Integra addition
// IE 11 needs Object.entries, but that's not covered by Angular / webpack es2015-polyfills.js
import 'core-js/es7/object';

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

5amfung picture 5amfung  路  3Comments

NCC1701M picture NCC1701M  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

hartjo picture hartjo  路  3Comments