Match-id-24ef5d2a5918f3b97b610d1cdd729c01e923f3e8

This commit is contained in:
* 2022-09-06 16:55:17 +08:00 committed by *
commit 63d3a5cadd
1 changed files with 8 additions and 5 deletions

View File

@ -25,6 +25,9 @@ export class WrappedEvent {
stopPropagation: () => void; stopPropagation: () => void;
preventDefault: () => void; preventDefault: () => void;
propagationStopped = false
isPropagationStopped = (): boolean => this.propagationStopped;
// 适配Keyboard键盘事件该函数不能由合成事件调用 // 适配Keyboard键盘事件该函数不能由合成事件调用
getModifierState?: (keyArgs: string) => boolean; getModifierState?: (keyArgs: string) => boolean;
// 适配老版本事件api // 适配老版本事件api
@ -39,7 +42,11 @@ export class WrappedEvent {
} }
} }
// stopPropagation和preventDefault 必须通过Event实例调用 // stopPropagation和preventDefault 必须通过Event实例调用
this.stopPropagation = () => nativeEvent.stopPropagation(); this.stopPropagation = () => {
nativeEvent.stopPropagation();
this.propagationStopped = true;
};
this.preventDefault = () => nativeEvent.preventDefault(); this.preventDefault = () => nativeEvent.preventDefault();
// custom事件自定义属性 // custom事件自定义属性
@ -58,10 +65,6 @@ export class WrappedEvent {
isDefaultPrevented(): boolean { isDefaultPrevented(): boolean {
return this.nativeEvent.defaultPrevented; return this.nativeEvent.defaultPrevented;
} }
isPropagationStopped(): boolean {
return this.nativeEvent.cancelBubble;
}
} }
// 创建普通自定义事件对象实例,和原生事件对应 // 创建普通自定义事件对象实例,和原生事件对应