Skip to content

Add an eventListenerOptions decorator #237

@justinfagnani

Description

@justinfagnani

lit/lit#531 adds support for declarative event listener options. We should support this with a decorator:

class MyElement extends LitElement {
  render() {
    return html`<button @click=${this.onClick}>Click Me</button>`;
  }

  @eventListenerOptions({capture: true})
  onClick(e) {
    console.log('clicked');
  }
}

We should also document that without decorators, users can simply set an attribute on the method directly:

MyElement.prototype.capture = true;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions