Fix explicit named slots ommited during component folding - #211
Merged
Conversation
Contributor
Author
|
@ganyicz Could you review this? I think I made a regression from previous PR, thanks! |
Contributor
Benchmark Result: Default
Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 47.74s total To run a specific benchmark, comment |
Collaborator
|
Oof good catch, thanks @ghabriel25 |
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.
Summary
Follow-up to #209: whitespace-only explicit named slots are registered as empty slots during folding instead of being dropped.
Problem
#209 correctly avoided creating non-empty placeholders for whitespace-only content (placeholders made
$slot->isEmpty()false during fold-time pre-render).For explicit named slots it used
continue, so the slot was omitted from$__slotsduring pre-render:$footerduring fold pre-renderComponentSlot('')aftertrim()$__slots)Fold treats slots as pass-through (placeholder → restore). Omitting the slot can break pre-render of templates that echo the named slot (
{{ $footer }}) when the only content is whitespace.Default
$slotis unaffected: Wrapper already does$__slots['slot'] ??= new ComponentSlot('').Changes
In
Foldable::setupSlots(), always register explicit slots:TextNode+slotByPlaceholder(unchanged)children([]), no placeholderImplicit default-slot behavior from #209 is unchanged: whitespace-only loose content does not synthesize a default slot.