Skip to content

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