0

In my ember app,I am using Object.values method, which is throwing the below error in IE browser.

Object doesn't support property or method 'values' TypeError: Object doesn't support property or method 'values'

In my package.json

"ember-cli-babel": "^6.3.0" 

my target.js file shows,

module.exports = {
  browsers: [
    'ie 9',
    'last 1 Chrome versions',
    'last 1 Firefox versions',
    'last 1 Safari versions'
  ]
};

I am using

ember-cli: 2.13.3
node: 6.3.1

Object.values is supported only in EDGE. How do I polyfill this in my ember project?. Similarly for String.endsWith I just the included the polyfill in app.js file. Here I want to use babel-polyfill so that it will automatically polyfill for the browser I mentioned in target.js

Ember Freak
  • 12,918
  • 4
  • 24
  • 54
  • [That same link you have about the support also has a section about polyfilling it](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values#Polyfill) – Patrick Evans Aug 18 '17 at 15:02
  • This file https://github.com/tc39/proposal-object-values-entries/blob/master/polyfill.js I tried then I got `Reflect` is not defined error. So I dont want to polyfill each time I use newer features, I just want to ember-cli to take care of it automatically. – Ember Freak Aug 18 '17 at 15:04

1 Answers1

1

ember-cli-babel comes with polyfill support configuration. I should have gone through their docs. I wasn't aware that the below configuration will do the magic.

// ember-cli-build.js

var app = new EmberApp(defaults, {
  'ember-cli-babel': {
    includePolyfill: true
  }
});

https://github.com/babel/ember-cli-babel#polyfill

Ember Freak
  • 12,918
  • 4
  • 24
  • 54
  • I mentioned in `ie 9` in target.js file so I thought ember-cli will do automatically polyfill. but that's not true but then it requires `includePolyfill: true` settings.. I dont know the reason for why do I have to mention `ie 9` in target.js file? – Ember Freak Aug 18 '17 at 15:26