You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when a property is used in template as event handler and later assigned a new value , old value is still used to handle the event (with this being undefined).
tested in Chrome : Version 131.0.6778.87 (Official Build) (arm64),
probably in all
Version
LWC: 8.11.0
Possible Solution
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
The text was updated successfully, but these errors were encountered:
gaurav-rk9
changed the title
property used in template as event handler is not reactive.
event handler does not update when the property bound to template with onevent is updated
Dec 6, 2024
exportdefaultclassextendsLightningElement{handler={onClick: ()=>{console.log('foo')}}connectedCallback(){this.handler.onClick=()=>{console.log('bar')}// this will be used}}
BTW the current behavior has some performance benefits, namely that we can bind/cache the event listener once rather than re-evaluating it. So fixing this may incur a performance cost.
Description
when a property is used in template as event handler and later assigned a new value , old value is still used to handle the event (with
this
beingundefined
).Steps to Reproduce
https://stackblitz.com/edit/salesforce-lwc-davchu?file=src%2Fmodules%2Fx%2Fcounter%2Fcounter.js
Expected Results
New value of
mainHandler
must be calledActual Results
Old value of
mainHandler
is calledBrowsers Affected
tested in Chrome : Version 131.0.6778.87 (Official Build) (arm64),
probably in all
Version
Possible Solution
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
The text was updated successfully, but these errors were encountered: