angular / angular/angular

zone.js cause "Unable to preventDefault inside passive event listener invocation." "errors", if passive handler is added first

未关闭
#45,020 6 条评论 6 个 reaction 已指派 1 人 已被 @JiaLiPassion 认领 在 GitHub 查看
area: zones P3
主要语言
TypeScript
星标
101k
派生
27.5k
平均合并
1 天 19 小时
30 天内合并 PR
288

描述

### Which @angular/* package(s) are the source of the bug?

Don't known / other

### Is this a regression?

No

### Description

There is issue with zone.js **addEventListener** patch. If you add listener with { passive: true } options first, same handler will be used for non-passive event listeners. As result calling event.preventDefault() causing error. Code example:

```
import 'zone.js';

document.addEventListener('mousemove', (ev) => {}, { passive: true });
document.addEventListener('mousemove', (ev) => {
ev.preventDefault(); // throws error
});
```

### Please provide a link to a minimal reproduction of the bug

Demo - https://js-dtyss2.stackblitz.io/
Code - https://stackblitz.com/edit/js-dtyss2

### Please provide the exception or error you saw

_No response_

### Please provide the environment you discovered this bug in (run `ng version`)

```
OS: win32 x64
Browser: Chrome 98

@zone.js 0.11.4
```

### Anything else?

_No response_

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。