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
{{ message }}
Repository navigation
Ref directive does not san-check its stored arg on disconnected/reconnected lifecycle #5217
❓ is the ref directive supposed to accept an undefined for argument?
Looks like that yes based on the exported types (that are derived from here
However, both the disconnected & reconnected lifecyles are doing unsafe usage of the ref.
I'll be glad to bring a fix upstream for that 🙂
However, I see two possible fixes, and I'd like to see which one we want to go with:
Either we consider the issue to be the looseness of the argument, and restrict it from RefCallback|undefined to RefCallback
Or, we go the opposite way and we ensure the internal _ref property is used safely.****
Thanks for making the issue. I think we need to go with this fix:
we ensure the internal _ref property is used safely
It's not super clear to me why supporting undefined as an actual ref argument is important, but it is tested (although obviously not on disconnection) so I think removing support could be called breaking-ish.
Activity
sorvell commentedon Jan 30, 2026
Thanks for making the issue. I think we need to go with this fix:
It's not super clear to me why supporting undefined as an actual
refargument is important, but it is tested (although obviously not on disconnection) so I think removing support could be called breaking-ish.PR welcome. Thanks!
fix(lit-html): +undef guard for updateRefValue in ref directive