Object.values() polyfill for <Fx47 after 269e2f8b
Zotero for Windows is still built with Fx45, so we need a polyfill for Object.values().
This commit is contained in:
parent
044ecf2157
commit
437c55b286
2 changed files with 12 additions and 0 deletions
|
@ -30,6 +30,8 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
Components.utils.import("resource://gre/modules/osfile.jsm");
|
Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
||||||
|
|
||||||
|
Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Core functions
|
* Core functions
|
||||||
*/
|
*/
|
||||||
|
|
10
resource/polyfill.js
Normal file
10
resource/polyfill.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
if (!Object.values) {
|
||||||
|
const reduce = Function.bind.call(Function.call, Array.prototype.reduce);
|
||||||
|
const isEnumerable = Function.bind.call(Function.call, Object.prototype.propertyIsEnumerable);
|
||||||
|
const concat = Function.bind.call(Function.call, Array.prototype.concat);
|
||||||
|
const keys = Reflect.ownKeys;
|
||||||
|
|
||||||
|
Object.values = function values(O) {
|
||||||
|
return reduce(keys(O), (v, k) => concat(v, typeof k === 'string' && isEnumerable(O, k) ? [O[k]] : []), []);
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue