-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: make insertions during iteration safe (#295)
This change addresses some unexpected behavior when inserting nodes into a container. For example, assume you have a container containing two class nodes `.foo.baz`. While iterating that container with `each`, assume you are processing `.foo` at index 0. Today, the behavior is as follows: - `insertBefore(.baz, .bar)` => the next callback is to `.baz` at idx 3 - `insertAfter(.foo, .bar)` => the next callback is to `.baz` at idx 3 - `prepend(.bar)` => the next callback is to `.foo` again at idx 1 With this change, the behavior is the following, respectively: - the next callback is to `.bar` at idx 2 - the next callback is to `.bar` at idx 2 - the next callback is to `.baz` at idx 3 The newly added tests demonstrate this behavior. I've also removed the old "container#each (safe iteration)" test, as it now creates an infinite loop. I'd argue that this is the expected behavior now, though.
- Loading branch information
1 parent
1b1e9c3
commit 4fa6e86
Showing
2 changed files
with
49 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters