Skip to content

Commit dd81603

Browse files
authored
Removing event listeners (#1120)
1 parent 7da810e commit dd81603

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/lit-dev-content/site/docs/v2/components/events.md

+4
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ When listening to events on repeated items, it's often convenient to use [event
168168

169169
{% playground-example "v2-docs/components/events/list/" "my-element.ts" %}
170170

171+
### Removing event listeners
172+
173+
Passing `null`, `undefined` or `nothing` to an `@` expression will cause any existing listener to be removed.
174+
171175
## Dispatching events { #dispatching-events }
172176

173177
All DOM nodes can dispatch events using the `dispatchEvent` method. First, create an event instance, specifying the event type and options. Then pass it to `dispatchEvent` as follows:

packages/lit-dev-content/site/docs/v3/components/events.md

+4
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ When listening to events on repeated items, it's often convenient to use [event
168168

169169
{% playground-example "v3-docs/components/events/list/" "my-element.ts" %}
170170

171+
### Removing event listeners
172+
173+
Passing `null`, `undefined` or `nothing` to an `@` expression will cause any existing listener to be removed.
174+
171175
## Dispatching events { #dispatching-events }
172176

173177
All DOM nodes can dispatch events using the `dispatchEvent` method. First, create an event instance, specifying the event type and options. Then pass it to `dispatchEvent` as follows:

0 commit comments

Comments
 (0)