ampproject / ampproject/worker-dom

event.preventDefault()

Open
#434 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.3k
Forks
154
PR merge metrics
No merged PRs in 30d

Description

Would be good to add support for preventing default actions of events.

One idea on how this might work: add an API that's something like `preventEventDefaultAction` to `HTMLElement`. This would allow replacing something like this:

```js
myForm.addEventListener('submit', (event) => {
event.preventDefault();
// ...
});
```

With this:

```js
myForm.preventEventDefaultAction('submit', true);
myForm.addEventListener('submit', (event) => {
// ...
});
```

Contributor guide

Open the contributing guide

Research direction

Start by reading the HTMLElement event API and the addEventListener handling described in the issue. Clarify the intended semantics for preventing a submit default action, then identify the relevant event tests and define coverage for the proposed API without changing existing event behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.