From a4f877587c8f1951f6802754ebd1840d0eaf6eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=A4=9A=E7=9B=8A?= Date: Thu, 15 Jun 2023 11:36:29 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20ios=20=E7=9A=84=20DragEvent=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E4=BF=AE=E5=A4=8D=E6=8C=AA=E5=88=B0=20core?= =?UTF-8?q?=20=E6=A8=A1=E5=9D=97=E4=B8=8B=20(#7154)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: ios 的 DragEvent 报错修复挪到主项目中 * chore: ios 的 DragEvent 报错修复挪到 core 模块下 --- examples/polyfills/index.ts | 7 ------- packages/amis-core/src/index.tsx | 1 + packages/amis-core/src/polyfills.ts | 10 ++++++++++ 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 packages/amis-core/src/polyfills.ts diff --git a/examples/polyfills/index.ts b/examples/polyfills/index.ts index 8e49cb9a2..c729415d0 100644 --- a/examples/polyfills/index.ts +++ b/examples/polyfills/index.ts @@ -18,10 +18,3 @@ import 'core-js/es/symbol'; import './cloest'; // @ts-ignore import './classList'; - -// ios 没有这个会报错 -if (!('DragEvent' in window)) { - Object.defineProperty(window, 'DragEvent', { - value: class DragEvent {} - }); -} diff --git a/packages/amis-core/src/index.tsx b/packages/amis-core/src/index.tsx index b8cce7cbc..aac8a827c 100644 --- a/packages/amis-core/src/index.tsx +++ b/packages/amis-core/src/index.tsx @@ -22,6 +22,7 @@ import { extendDefaultEnv } from './factory'; import type {RenderOptions, RendererConfig, RendererProps} from './factory'; +import './polyfills'; import './renderers/builtin'; import './renderers/register'; export * from './utils/index'; diff --git a/packages/amis-core/src/polyfills.ts b/packages/amis-core/src/polyfills.ts new file mode 100644 index 000000000..c3417345b --- /dev/null +++ b/packages/amis-core/src/polyfills.ts @@ -0,0 +1,10 @@ +/** + * 用于放一些关键的 polyfill + */ + +// ios 老版本没有这个会报错 +if (!('DragEvent' in window)) { + Object.defineProperty(window, 'DragEvent', { + value: class DragEvent {} + }); +}