IE8 will throw "ERR_ACCESSORS_NOT_SUPPORTED" error when using Object.defineProperty in es5-shim.js
EricTiger1986 opened this issue · 3 comments
When running the codes like (please see below) in IE8 with es5-sham.js, es5-sham.js will throw an error (ERR_ACCESSORS_NOT_SUPPORTED) since IE8 doesn't support function defineGetter. Is there any workaround about this issue? Thank you in advance.
Object.defineProperty(DOMElement.prototype, 'localName', {
get: function () {
return this.getName()
}
})
There is no workaround. ES5 getters and setters are utterly incompatible with IE 8 and below.
The only solution is to simply not use this language feature.
(Separately, please don't modify things you don't own, like DOMElement.prototype
)
Thank you for your suggestion. But these codes are in the third part module I require in my project. The project can work well in IE9+, so I cannot re-code this project.
Not sure what to tell you - if that third-party module uses getters and setters, and you use it, then your site/app simply can't work in IE 8. You'll have to choose between using that module, and supporting IE 8.