angular / angular

Deliver web apps with confidence 🚀
https://angular.dev
MIT License
94.98k stars 24.85k forks source link

fix(zone.js): do not mutate event listener options (may be readonly) #55796

Closed arturovt closed 3 weeks ago

arturovt commented 1 month ago

Prior to this commit, event listener options were mutated directly, for example, options.signal = undefined or options.once = false.

This issue arises in apps using third-party libraries where the responsibility lies with the library provider. Some libraries, like WalletConnect, pass an abort controller as addEventListener options. Because the abort controller has the signal property, this is a valid case. Thus, mutating options would throw an error since signal is a readonly property.

Even though zone.js is being deprecated as Angular moves towards zoneless change detection, this fix is necessary for apps that still use zone.js and cannot migrate to zoneless change detection because they rely on third-party libraries and are not responsible for the code used in them.

Closes #54142

AndrewKushnir commented 4 weeks ago

Global Presubmit.

AndrewKushnir commented 3 weeks ago

Caretaker note: TGP is "green" (except for unrelated build breakages), this PR is ready for merge.

dylhunn commented 3 weeks ago

This PR was merged into the repository by commit 85c171920ae2b1861896fa6c2d5d7dc8f030a445.