Skip to content

Commit

Permalink
Make Event#preventDefault() only work when cancelable: true
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Nov 13, 2023
1 parent 16492f8 commit 28addd4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-adults-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nxjs-runtime': patch
---

Make `Event#preventDefault()` only work when `cancelable: true`
6 changes: 4 additions & 2 deletions packages/runtime/src/polyfills/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ export class Event implements globalThis.Event {
throw new Error('Method not implemented.');
}
preventDefault(): void {
// @ts-expect-error - `defaultPrevented` is readonly
this.defaultPrevented = true;
if (this.cancelable) {
// @ts-expect-error - `defaultPrevented` is readonly
this.defaultPrevented = true;
}
}
stopImmediatePropagation(): void {
throw new Error('Method not implemented.');
Expand Down

0 comments on commit 28addd4

Please sign in to comment.