fix: preserve source order for shared structural slots - #465
Merged
Mohamed Mansour (mohamedmansour) merged 5 commits intoAug 24, 2026
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mohamed Mansour (mohamedmansour)
force-pushed
the
mohamedmansour-prove-nested-loop-order
branch
from
August 24, 2026 19:41
45010a9 to
043d4b1
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mohamed Mansour (mohamedmansour)
requested review from
Bang Lee (Qusic),
Akrosh Gandhi (akroshg) and
mcritzjam
August 24, 2026 20:25
mcritzjam
approved these changes
Aug 24, 2026
Mohamed Mansour (mohamedmansour)
deleted the
mohamedmansour-prove-nested-loop-order
branch
August 24, 2026 22:16
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.
Client-created repeat items can still render adjacent dynamic regions out of template order on current
main. A nested<for>followed by a trailing<if>produces the conditional first, while SSR and refresh preserve the declared order.The compiler already emits
TemplateSlot.order, but$wire()previously inserted text, conditional, and repeat nodes in separate type batches. When different binding kinds shared one static insertion point, their DOM order followed the batch order instead of the template.This change keeps each binding section explicit while using one small placement model:
PendingSlotcontaining its parent, static reference, compiler order, node, and optional raw-HTML end anchor.insertPendingSlots()sorts only when slots collide, then commits all nodes after every reference has been captured from the untouched DOM.The reactive update path is unchanged: bindings still retain direct DOM references, with no virtual DOM and no new per-update work.
Reduced regression coverage proves:
<for>-><if>and<if>-><for>orderA shared-slot hydration benchmark keeps the high-collision shape measurable.
Validation after rebasing onto
origin/main:pnpm test: 319 unit tests passed; 263 Playwright tests passed, 2 skippedcargo xtask check: all phases passed