Repository navigation
Conversation
Since Alpine 3.15.9, keyed x-for moves only the item element and, for x-if, its single rendered element. The content of x-fragment, x-when and x-match was rendered before the template and was left behind, so reordering mixed up the blocks. Render the content after the template, like x-if, and expose its last node through _x_currentIfEl and _x_lastRenderedEl, so x-for treats the whole block as the item. The shared mutation observer then restores the content of every block in the affected parent right after its template, following nested blocks and x-if. The observer also handles removed nodes and the records produced by deleting nested blocks, and works with Alpine versions that do not expose the last rendered item of x-for or destroy x-if content. Fixes #62
Cover reordering, adding, removing and toggling the items of a keyed x-for for x-fragment, x-when and x-match, checking the exact node layout and that the existing nodes are moved rather than recreated. For x-fragment, check all transitions between the orders of four items. Also cover nested blocks, x-if inside a block and vice versa, a block containing a keyed x-for of blocks, restoring a moved node of a block, keeping the initial content of nested x-if and x-for, and that the observer settles without a feedback loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
📦 Bundle size comparison
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.