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 件 担当者 1 名 @JiaLiPassion が担当を希望しています GitHub で見る
area: zones P3
主要言語
TypeScript
スター
101k
フォーク
27.5k
平均マージ
1日 19時間
マージ済み PR(30日)
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 を短くまとめたダイジェスト。