Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent infinite looping in target callbacks #459

Merged
merged 1 commit into from
Oct 7, 2021

Conversation

seanpdoyle
Copy link
Contributor

Prior to this change, adding or removing target elements could result in
an infinite loop of callbacks and mutations.

This commit introduces ElementObserver.pause() (and transitively
introduces AttributeObserver.pause() and TokenListObserver.pause())
to provide callers with the ability to pause and resume mutation
observation.

When firing [name]TargetConnected and [name]TargetDisconnected
callbacks, the behind-the-scenes observers are paused.

Prior to this change, adding or removing target elements could result in
an infinite loop of callbacks and mutations.

This commit introduces `ElementObserver.pause()` (and transitively
introduces `AttributeObserver.pause()` and `TokenListObserver.pause()`)
to provide callers with the ability to pause and resume mutation
observation.

When firing `[name]TargetConnected` and `[name]TargetDisconnected`
callbacks, the behind-the-scenes observers are paused.
@dhh dhh merged commit 3128ef1 into hotwired:main Oct 7, 2021
@seanpdoyle seanpdoyle deleted the target-looping-bug branch October 10, 2021 14:39
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.

2 participants