web: add Iterator.map polyfill for firefox 128

This commit is contained in:
Tulir Asokan 2024-11-04 12:06:30 +02:00
parent c14c079d44
commit b63a81ba65
3 changed files with 29 additions and 1 deletions

View file

@ -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(

27
web/src/util/polyfill.js Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
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
}
}

View file

@ -5,7 +5,7 @@ import svgr from "vite-plugin-svgr"
export default defineConfig({
base: "./",
build: {
target: ["esnext", "firefox132"],
target: ["esnext", "firefox128"],
},
plugins: [
react(),