commit 437c55b286a2aa841fa4804c806d71fe7e61c325
parent 044ecf21577e65563e3abfd9602d20d2f462d535
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 26 Dec 2016 15:17:19 -0500
Object.values() polyfill for <Fx47 after 269e2f8b
Zotero for Windows is still built with Fx45, so we need a polyfill for
Object.values().
Diffstat:
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -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/PluralForm.jsm");
+Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
+
/*
* Core functions
*/
diff --git a/resource/polyfill.js b/resource/polyfill.js
@@ -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]] : []), []);
+ };
+}