From b63a81ba65047e24ed3e2107c112b02756b06a06 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 4 Nov 2024 12:06:30 +0200 Subject: [PATCH] web: add Iterator.map polyfill for firefox 128 --- web/src/main.tsx | 1 + web/src/util/polyfill.js | 27 +++++++++++++++++++++++++++ web/vite.config.ts | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 web/src/util/polyfill.js diff --git a/web/src/main.tsx b/web/src/main.tsx index 173a9d9..783c9e6 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -16,6 +16,7 @@ import { StrictMode } from "react" import { createRoot } from "react-dom/client" import App from "./App.tsx" +import "./util/polyfill.js" import "./index.css" createRoot(document.getElementById("root")!).render( diff --git a/web/src/util/polyfill.js b/web/src/util/polyfill.js new file mode 100644 index 0000000..503c4f3 --- /dev/null +++ b/web/src/util/polyfill.js @@ -0,0 +1,27 @@ +// gomuks - A Matrix client written in Go. +// Copyright (C) 2024 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +if (!Iterator.prototype.map) { + Iterator.prototype.map = function(callbackFn) { + const output = [] + let i = 0 + for (const item of this) { + output.push(callbackFn(item, i)) + i++ + } + return output + } +} diff --git a/web/vite.config.ts b/web/vite.config.ts index 072131a..493470b 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -5,7 +5,7 @@ import svgr from "vite-plugin-svgr" export default defineConfig({ base: "./", build: { - target: ["esnext", "firefox132"], + target: ["esnext", "firefox128"], }, plugins: [ react(),