Skip to content

Commit

Permalink
docs(preventdefault): add info about passive listener (#36098)
Browse files Browse the repository at this point in the history
* Update index.md

* Update files/en-us/web/api/event/preventdefault/index.md

Co-authored-by: Joshua Chen <[email protected]>

* Update files/en-us/web/api/event/preventdefault/index.md

Co-authored-by: Joshua Chen <[email protected]>

* Update index.md

---------

Co-authored-by: Joshua Chen <[email protected]>
  • Loading branch information
zhangenming and Josh-Cena authored Sep 30, 2024
1 parent 6d4333c commit a845f9d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions files/en-us/web/api/event/preventdefault/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ non-cancelable event, such as one dispatched via
{{domxref("EventTarget.dispatchEvent()")}}, without specifying
`cancelable: true` has no effect.

If a passive listener calls `preventDefault()`, nothing will happen and a console warning may be generated.

## Syntax

```js-nolint
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/eventtarget/addeventlistener/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ addEventListener(type, listener, useCapture)
`listener` would be automatically removed when invoked. If not specified, defaults to `false`.
- `passive` {{optional_inline}}

- : A boolean value that, if `true`, indicates that the function specified by `listener` will never call {{domxref("Event.preventDefault", "preventDefault()")}}. If a passive listener does call `preventDefault()`, the user agent will do nothing other than generate a console warning.
- : A boolean value that, if `true`, indicates that the function specified by `listener` will never call {{domxref("Event.preventDefault", "preventDefault()")}}. If a passive listener calls `preventDefault()`, nothing will happen and a console warning may be generated.

If this option is not specified it defaults to `false` – except that in browsers other than Safari, it defaults to `true` for {{domxref("Element/wheel_event", "wheel")}}, {{domxref("Element/mousewheel_event", "mousewheel")}}, {{domxref("Element/touchstart_event", "touchstart")}} and {{domxref("Element/touchmove_event", "touchmove")}} events. See [Using passive listeners](#using_passive_listeners) to learn more.

Expand Down

0 comments on commit a845f9d

Please sign in to comment.