From ad92bc1253433650bd189a79a2e10138664e31af Mon Sep 17 00:00:00 2001 From: lvxiaojiao Date: Wed, 6 Dec 2023 19:11:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dapi=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=8C=85=E5=90=ABevent=E5=8F=98=E9=87=8F=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis-core/src/utils/renderer-event.ts | 59 ++++++++++++------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/packages/amis-core/src/utils/renderer-event.ts b/packages/amis-core/src/utils/renderer-event.ts index c8ce9e96a15..b3f54d59c86 100644 --- a/packages/amis-core/src/utils/renderer-event.ts +++ b/packages/amis-core/src/utils/renderer-event.ts @@ -72,31 +72,50 @@ export function createRendererEvent( type: string, context: T ): RendererEvent { - const rendererEvent = { - context: extendObject({pristineData: context.data}, context), - type, - prevented: false, - stoped: false, - preventDefault() { - rendererEvent.prevented = true; - }, + const rendererEvent: RendererEvent = Object.defineProperties( + { + context: extendObject({pristineData: context.data}, context), + type, + prevented: false, + stoped: false, + preventDefault() { + rendererEvent.prevented = true; + }, - stopPropagation() { - rendererEvent.stoped = true; - }, + stopPropagation() { + rendererEvent.stoped = true; + }, - get data() { - return rendererEvent.context.data; - }, + get data() { + return rendererEvent.context.data; + }, - get pristineData() { - return rendererEvent.context.pristineData; - }, + get pristineData() { + return rendererEvent.context.pristineData; + }, - setData(data: any) { - rendererEvent.context.data = data; + setData(data: any) { + rendererEvent.context.data = data; + } + }, + { + context: { + enumerable: false + }, + pristineData: { + enumerable: false + }, + preventDefault: { + enumerable: false + }, + stopPropagation: { + enumerable: false + }, + setData: { + enumerable: false + } } - }; + ); return rendererEvent; }