Match-id-6c100f1d01da9e17e32d09176e40d5da6087ede5

This commit is contained in:
* 2022-09-06 14:43:50 +08:00 committed by *
parent b69ebe308a
commit 7b4a54c2e6
1 changed files with 8 additions and 5 deletions

View File

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