@eventOptions decorator sets addEventListener options on a method so that when
the method is used as an event listener in a lit-html template (e.g. @click=${this._onClick}),
Lit passes those options when adding the listener.
Import
Signature
Options
When
true, the listener is invoked during the capture phase before the
event reaches its target.When
true, the listener will never call preventDefault(). Marking
scroll and touch handlers as passive can significantly improve scrolling
performance.When
true, the listener is automatically removed after it is invoked
for the first time.Usage
Passive scroll listener
Capture phase listener
How it works
The decorator assigns the option properties directly onto the method function object. When lit-html binds an event listener using the@event syntax and the bound value is
an object with handleEvent or a function with event listener options attached,
Lit passes those options to addEventListener.
@eventOptions only takes effect when the decorated method is used with Lit’s
event binding syntax (@event=${this._handler}). It has no effect when the method
is passed to addEventListener directly.