From 87f0992ae55f5f7ee1dffc7d50fc969989eba982 Mon Sep 17 00:00:00 2001 From: haorwen Date: Sun, 18 Jan 2026 08:42:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BD=8E=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=B5=8F=E8=A7=88=E5=99=A8=E4=B8=8D=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=20(#301)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add polyfills for Array.prototype.at and String.prototype.at methods * chore: bump version to v0.9.51 --- package.json | 2 +- src/libs/polyfills.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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]; + }; +}