Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object doesn't support property or method 'keys' - (IE11)

I can't figure out what is the problem in IE11.
App works well without any issue in other browsers like chrome, firefox etc.


enter image description here

like image 755
Nikhil Shah Avatar asked Feb 16 '16 10:02

Nikhil Shah


Video Answer


2 Answers

You need to include es6-shim because IE 11 doesn't support Map.prototype.keys

https://github.com/paulmillr/es6-shim

Or you can import directly from cdn:

<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.4.1/es5-shim.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.1/es6-shim.js"></script>

Check this related issues:

  • https://github.com/angular/angular/issues/6479
  • https://github.com/mgechev/angular2-seed/issues/145
like image 122
Joel Almeida Avatar answered Oct 16 '22 23:10

Joel Almeida


"The use of a keyword for an identifier in invalid" on IE 11 is still an issue for Angular2 beta 6:

http://github.com/angular/angular/issues/6501

In the thread, there is a work-around that seems to work:

// function.name (all IE)
/*! @source http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie*/
if (!Object.hasOwnProperty('name')) {
  Object.defineProperty(Function.prototype, 'name', {
    get: function() {
      var matches = this.toString().match(/^\s*function\s*(\S[^\(]*)\s*\(/);
      var name = matches && matches.length > 1 ? matches[1] : "";
      // For better performance only parse once, and then cache the
      // result through a new accessor for repeated access.
      Object.defineProperty(this, 'name', {value: name});
      return name;
    }
  });
}
like image 26
pixelbits Avatar answered Oct 16 '22 23:10

pixelbits