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
The ref directive supplies an element when it runs update and it is in a disconnected state. This does not make sense since ref supplies undefined when disconnected and the element again when reconnected. Since this behavior implies that ref is intended to supply undefined when disconnected, it's incorrect for this to change while it is disconnected.
This can cause practical problems if code depends on installing/removing behavior based on connection state. See discord discussion.
Note also that checking refElement.isConnected is not a workaround since directives are run in a connected state regardless of whether or not the host context is connected.
Note that:
A. After (3) the ref callback is supplied when an element. This is unexpected.
B. After (4) the ref callback gets undefined and then the element. This is unexpected.
Workaround
Gate behavior on the host's connection state.
Is this a regression?
No or unsure. This never worked, or I haven't tried before.
Affected versions
3.x
Browser/OS/Node environment
All
The text was updated successfully, but these errors were encountered:
Which package(s) are affected?
Lit Core (lit / lit-html / lit-element / reactive-element)
Description
The
ref
directive supplies an element when it runs update and it is in a disconnected state. This does not make sense sinceref
suppliesundefined
when disconnected and the element again when reconnected. Since this behavior implies thatref
is intended to supplyundefined
when disconnected, it's incorrect for this to change while it is disconnected.This can cause practical problems if code depends on installing/removing behavior based on connection state. See discord discussion.
Note also that checking
refElement.isConnected
is not a workaround since directives are run in a connected state regardless of whether or not the host context is connected.Reproduction
In the repro example here https://lit.dev/playground/#gist=fe6d7deeba80b76873eb057819ed2bc4
Note that:
A. After (3) the ref callback is supplied when an element. This is unexpected.
B. After (4) the ref callback gets undefined and then the element. This is unexpected.
Workaround
Gate behavior on the host's connection state.
Is this a regression?
No or unsure. This never worked, or I haven't tried before.
Affected versions
3.x
Browser/OS/Node environment
All
The text was updated successfully, but these errors were encountered: