Skip to content

Value of "this" #4488

Answered by augustjk
jchome asked this question in Q&A
Jan 11, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

What's the goal you're trying to achieve? How to use it correctly depends on what you're trying to do.

There's a bit of "magic" involved when passing a function to the @event binding because the context of this is bound to the element it's on unless specified otherwise as a host option https://lit.dev/docs/libraries/standalone-templates/#render-options

You can bind the context of this in the event handler by using arrow functions instead too.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@justinfagnani
Comment options

@jchome
Comment options

Answer selected by jchome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants