Skip to content

Conversation

@ildarkayumov
Copy link

Fixes #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 so this.scopeReferenceCounts is eq 2.
and during ScopeObserver#elementUnmatchedValue this counter this.scopeReferenceCounts remains >= 1 so scopeDisconnected(value) is not called

this.connectedContexts.add(context)
context.connect()

if (!this.connectedContexts.has(context)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need this to prevent double controller#connect

@sebastianludwig
Copy link

sebastianludwig commented May 28, 2024

I can confirm that this PR resolves the initially reported issue in #763 🎉 Thank you very much!

@ildarkayumov
Copy link
Author

@marcoroth can you check this please?

@nemesit
Copy link

nemesit commented Oct 17, 2024

Would be nice if this could be merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

disconnect() not called if outlet is accessed in connect()

3 participants