Next.js: Object.keys non-object coercion not working in IE 11

Created on 11 May 2020  路  4Comments  路  Source: vercel/next.js

Bug 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

  1. Download the reproduction available at https://github.com/tomdohnal/object-keys-ie-repro
  2. Use yarn dev or npm run dev to start the development server
  3. 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]
needs investigation

Most helpful comment

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.

All 4 comments

Could you please test this on next@canary?

I've just tested it and it's still broken on next@canary

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...

Was this page helpful?
0 / 5 - 0 ratings