From 9e522b033079e47c8c9c26256dc6fa1dbbf20562 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 11 Sep 2024 19:22:31 +0300 Subject: [PATCH] #1358 Add findLastIndex polyfill for old Safari --- public/index.html | 2 +- public/lib/object-hasown.js | 4 ---- public/lib/polyfill.js | 13 +++++++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) delete mode 100644 public/lib/object-hasown.js create mode 100644 public/lib/polyfill.js diff --git a/public/index.html b/public/index.html index 61e4c207b..6f8c87112 100644 --- a/public/index.html +++ b/public/index.html @@ -6479,8 +6479,8 @@ + - diff --git a/public/lib/object-hasown.js b/public/lib/object-hasown.js deleted file mode 100644 index 9b7792e88..000000000 --- a/public/lib/object-hasown.js +++ /dev/null @@ -1,4 +0,0 @@ -// Polyfill for old Safari versions -if (!Object.hasOwn) { - Object.hasOwn = function (obj, prop) { return obj.hasOwnProperty(prop); } -} diff --git a/public/lib/polyfill.js b/public/lib/polyfill.js new file mode 100644 index 000000000..b46d73906 --- /dev/null +++ b/public/lib/polyfill.js @@ -0,0 +1,13 @@ +// Polyfills for old Safari versions +if (!Object.hasOwn) { + Object.hasOwn = function (obj, prop) { return obj.hasOwnProperty(prop); } +} + +if (!Array.prototype.findLastIndex) { + Array.prototype.findLastIndex = function (callback, thisArg) { + for (let i = this.length - 1; i >= 0; i--) { + if (callback.call(thisArg, this[i], i, this)) return i; + } + return -1; + }; +}