diff --git a/package.json b/package.json index f17c3270..73df65f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vocechat-web", - "version": "0.9.50", + "version": "0.9.51", "homepage": "https://voce.chat", "dependencies": { "@metamask/onboarding": "^1.0.1", diff --git a/src/libs/polyfills.js b/src/libs/polyfills.js index c11d287c..34016633 100644 --- a/src/libs/polyfills.js +++ b/src/libs/polyfills.js @@ -18,3 +18,26 @@ if (!isSupported) { } // hasown API "hasOwn" in Object || (Object.hasOwn = Object.call.bind(Object.hasOwnProperty)); + +// Array.prototype.at() and String.prototype.at() polyfill +if (!Array.prototype.at) { + Array.prototype.at = function (index) { + const len = this.length; + const relativeIndex = index >= 0 ? index : len + index; + if (relativeIndex < 0 || relativeIndex >= len) { + return undefined; + } + return this[relativeIndex]; + }; +} + +if (!String.prototype.at) { + String.prototype.at = function (index) { + const len = this.length; + const relativeIndex = index >= 0 ? index : len + index; + if (relativeIndex < 0 || relativeIndex >= len) { + return undefined; + } + return this[relativeIndex]; + }; +}