Repository navigation
Engine: Keep <Fragment> fallbacks in the tree while other visitors run - #2654
Merged
Merged
Conversation
marcoroth
enabled auto-merge (squash)
September 14, 2026 19: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.
A
<Fragment>'s<Fallback>came out of a compile without the scope attribute a<style scoped>block gives every other element, so the markup a client stands in while content is stale rendered unstyled.The
<i>the client swaps in came back as<i class="g">, while the CSS it needs compiles to.g[data-herb-scope-…].The fallback is the only markup that leaves the tree this early.
Fragment#transformreturns just the conditional it synthesizes and hands the fallback body to the visitor to keep, so from that moment the body is reachable only through@fragment_fallbacks. It comes back atfinish, as an entry in the statics the client rebuilds from. The engine runs every visitor's pass before it runs any visitor'sfinish, so a visitor that walks the tree after the slots visitor never sees the fallback, and one that writes into markup leaves it out.ScopedStyle::Visitorwrites the scope attribute andSourceAttributionVisitorwritesdata-herb-source, and both missed it.A conditional's arms do not have this problem, which is what made it look like scoped styles and parked markup work together.
park_branchserializes an arm duringfinish, by which point every visitor has already written what it was going to write. Only the fallback is taken out mid-pass.So the fallback now stands in the document for as long as the other visitors run. The slots visitor appends it once its own pass is done, and takes it back out at the top of
finish, before anything reads the document to compile it. Nothing about the output changes except that the fallback carries what the other visitors wrote. It still never renders inline, and it still reaches the client through the same statics entry, which holds the same nodes.The test that covers it compiles the template above and snapshots it, so the parked arm has to show the attribute:
It sits next to the test that already pins the same thing for a conditional's arms, and it fails without this change.