-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: Enable support for event bindings in Template Engine. #120
Comments
I'm opposed to adding this functionality, but I wanted to open this issue up since this behavior is common in other templating engines. |
I'll chime in here to say that one thing that template event binding allows for is the ability to bind to dynamically instantiated elements--such as sub-elements in a For the most part, the same thing can logically be achieved using event delegation or custom events that are listened to at the host level, but there are some instances where directly binding is substantially more ergonomic. For example, consider the following:
In order to do something logically similar using listen/unlisten, you could delegate the Alternatively, you could create a custom element for the table row header cell, and rely on css in order to make it behave the same as a native In addition, I'll add that I personally prefer template event binding because it's one fewer opportunity for a mapping error--it's always possible to typo a |
Hi @chen-ye! Thanks for your comment, it definitely helps weigh pros / cons to these choices. I'll add another argument to my top comment. Mainly, I will also add that the move to have |
Authors can already leverage the
listeners
block orlisten
/unlisten
methods inconnectedCallback
/disconnectedCallback
to manage event handling. An event binding would potentially provide a more ergonomic solution, maybe.Why we might add it:
Why we might not add it:
lit-html
oruhtml
if this is desired.Proposal
Users would be able to declare something like the following to add an event handler:
The text was updated successfully, but these errors were encountered: