[lit-html] Fix ref directive crash when passed undefined during lifec…#5231
[lit-html] Fix ref directive crash when passed undefined during lifec…#5231Nitin75408 wants to merge 1 commit into
Conversation
|
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary
_updateRefValueelse branch withelse if (this._ref !== undefined)to prevent TypeError when setting.valueonundefineddisconnected()andreconnected()whenthis._refisundefinedAsyncDirective.isConnectedfrom!definite assignment (isConnected!: boolean) to safe default (isConnected = false) so it is neverundefinedat runtimeDirective._$isConnectedgetter to use optional chaining (this._$parent?._$isConnected ?? false) to handle uninitialized parent referencesTest plan
ref(undefined)during disconnect, reconnect, multiple cycles, ref switching, and re-render while disconnectedFixes #5217