ソースを参照

fix: MediaQueryList addEventListener polyfill

GyDi 2 年 前
コミット
fd6633f536
2 ファイル変更22 行追加0 行削除
  1. 1 0
      src/main.tsx
  2. 21 0
      src/utils/polyfill.ts

+ 1 - 0
src/main.tsx

@@ -1,6 +1,7 @@
 /// <reference types="vite/client" />
 /// <reference types="vite-plugin-svgr/client" />
 import "./assets/styles/index.scss";
+import "@/utils/polyfill";
 
 import React from "react";
 import ReactDOM from "react-dom";

+ 21 - 0
src/utils/polyfill.ts

@@ -0,0 +1,21 @@
+// matchMedia polyfill for macOS 10.15
+if (
+  window.MediaQueryList &&
+  !window.MediaQueryList.prototype.addEventListener
+) {
+  window.MediaQueryList.prototype.addEventListener = function (
+    name: string,
+    callback: any
+  ) {
+    this.addListener(callback);
+  };
+
+  window.MediaQueryList.prototype.removeEventListener = function (
+    name: string,
+    callback: any
+  ) {
+    this.removeListener(callback);
+  };
+}
+
+export {};