为什么Chrome会发出PointerEvents和FirefoxMouseEvents,我应该在代码中使用哪种类型定义

bihw5rsg  于 12个月前  发布在  Go
关注(0)|答案(1)|浏览(126)

我对类型脚本有些陌生,并试图在尽可能精确的情况下向所有方法添加类型定义。
当我在Chrome中单击时,会发出PointerEvent。在Firefox中,会发出MouseEvent。我知道PointerEvent扩展了MouseEvent,根据https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent#browser_compatibility,Firefox也支持这些。
1.为什么Chrome会发出与火狐不同的事件
1.我应该在事件侦听器中使用哪种类型(可能是MouseEvent
1.最重要的是,如果两者显示的内容不同,我该如何确定?(a.k. a信任Chrome安全吗,还是我必须查阅文档?)

h5qlskok

h5qlskok1#

这似乎是Firefox中的一个bug:https://bugzilla.mozilla.org/show_bug.cgi?id=1675847
在Safari中:https://bugs.webkit.org/show_bug.cgi?id=218665
根据规格:https://www.w3.org/TR/uievents/#event-type-click应该是PointerEvent
因此,在修复这些错误之前,只需使用MouseEvent,因为PointerEvent继承自MouseEvent(https://www.w3.org/TR/pointerevents3/#pointerevent-interface)

相关问题