Object.keys non-object coercion not working in IE 11
See original GitHub issueBug report
Describe the bug
The argument passed to the Object.keys
method should be coerced to an object from ES2015 onward.
As illustrated in the example taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys.
// In ES5
Object.keys('foo'); // TypeError: "foo" is not an object
// In ES2015+
Object.keys('foo'); // ["0", "1", "2"]
However, this behaviour is not pollyfilled in Next.js for IE 11.
To Reproduce
- Download the reproduction available at https://github.com/tomdohnal/object-keys-ie-repro
- Use
yarn dev
ornpm run dev
to start the development server - Open the page in IE 11 and it crashes.
Expected behavior
It should coerce the argument passed to Object.keys to object and not crash.
System information
- OS: [Windows 10]
- Browser [e.g. IE 11]
- Version of Next.js: [e.g. 9.3.6]
- Version of Node.js: [e.g. 12.14.0]
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Object.keys not working in internet Explorer - Stack Overflow
Object.keys is not avaiable in IE < 9. As a simple workaround you could use: if (!Object.keys) { Object.keys = function(obj) { var...
Read more >Object.keys() - JavaScript - MDN Web Docs
Non -object arguments are coerced to objects. Only strings may have own enumerable properties, while all other primitives return an empty array.
Read more >Object.keys() - The Vanilla JS Toolkit
Object.keys() polyfill */ // From ... 'object' || obj === null)) { throw new TypeError('Object.keys called on non-object'); } var result = [],...
Read more >Object.preventExtensions() - JavaScript
The Object.preventExtensions() method prevents new properties from ever being added to an object (i.e. prevents future extensions to the object).
Read more >Object orientation - The Apache Groovy programming language
The key differences between Groovy classes and their Java counterparts are: Classes or methods with no visibility modifier are automatically public (a special ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ooh,
Object.keys
exists in IE9 it seems. I do not believe we override existing browser globals to introduce new behavior. Let’s take a deeper look into this though.Yeah it exists but lacks the coercion functionality which was added as a part of the ES6 spec…