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; }