The problem occurs when Outlet is accessed before controller has been connected by Stimulus and somebody tries to disconnect such controller later.
in such case ScopeObserver#elementMatchedValue is called 2 times so this.scopeReferenceCounts is eq 2.
and during ScopeObserver#elementUnmatchedValue this counter this.scopeReferenceCounts remains >= 1 so scopeDisconnected(value) is not called
Fixes https://github.com/hotwired/stimulus/issues/763
The problem occurs when Outlet is accessed before controller has been connected by Stimulus and somebody tries to disconnect such controller later.
in such case
ScopeObserver#elementMatchedValue
is called 2 times sothis.scopeReferenceCounts
is eq 2. and duringScopeObserver#elementUnmatchedValue
this counterthis.scopeReferenceCounts
remains >= 1 soscopeDisconnected(value)
is not called