Fix @aware resolution when folding across template boundaries#189
Open
calebporzio wants to merge 2 commits into
Open
Fix @aware resolution when folding across template boundaries#189calebporzio wants to merge 2 commits into
calebporzio wants to merge 2 commits into
Conversation
When a foldable component that consumes @AWare props is compiled at the root of a template (an @include partial or a nested component's view), its real parent is only knowable at runtime, so folding baked in the prop defaults. A <flux:select.option> rendered through a partial inside a <flux:select variant="listbox"> folded to the default variant's markup instead of the listbox variant's. Now such components are left unfolded so @AWare resolves at runtime, and folded parents detect @AWare consumers behind includes and nested component templates so they push their data for that runtime lookup. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Since the temporary fold cache started persisting between compiles, a process reusing a cached compiled file had no in-memory replacement for the @unblaze tokens baked into it, causing an undefined array key at render and silently aborting the fold. Store the replacement content in the compiled file itself so any process that renders it repopulates the map, and purge the cache when a stale token from an older format is encountered. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Benchmark Result: Default
Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 46.16s total To run a specific benchmark, comment |
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.
Fixes #186
Root cause
Two separate bugs, both surfaced in #186:
1. Folding bakes in wrong
@awarevalues across template boundaries (the actual<flux:select>crash).When a foldable component that consumes
@awareprops sits at the root of a template — i.e. it's rendered through an@includepartial or from a nested component's view — its real parent only exists at runtime. The folder resolved@awarelexically, found nothing, and baked in the prop defaults.Concretely:
<flux:select.option>declares@aware(['variant', 'indicator']). Rendered through a partial inside<flux:select variant="listbox">, it folded to the default variant's native<option>markup instead of the listbox's<ui-option>markup. flux.js then finds no& > ui-optionchildren in the listbox, treats the list as empty, and hitscreate._activatable.activate(true)in a state it never expects — the uncaught TypeError kills init for every select on the page. This matches the reporter's repro matrix exactly (inline children fold correctly because the parent is lexically visible; slot/include boundaries crash).2. The temporary fold cache goes stale across processes (
Undefined array keyatUnblaze.php:87).Since #116 the temporary fold cache persists between compiles, but
Unblaze::$unblazeReplacementsonly ever lived in memory in the process that compiled the file. Any other process reusing a cached compiled file (with[STARTCOMPILEDUNBLAZE:…]tokens baked in) missed the lookup, logged the undefined key warning the reporter found, and silently aborted the fold.Fix
@awareprops can't be resolved from the template itself (not passed directly, no value from a lexically visible parent, and no component ancestors in the template) — it renders normally and@awareresolves at runtime.hasAwareDescendant()now also detects@awareconsumers hiding behind@include/@eachand nested component templates (recursive source scan), so folded parents still push their data for that runtime lookup.@unblazereplacement content is now stored from within the compiled file itself (base64-encoded), so any process that renders a cached file repopulates the replacement map. Stale files from older versions purge the temp cache and abort the fold gracefully once.Tests
ComparisonTest:@awarethrough an include partial and through a nested component (both fail on main, byte-identical to Blade after the fix).FluxProTest: the exact @blaze folding breaks Flux <flux:select> — uncaught _activatable TypeError destroys all selects on the page #186 scenario —<flux:select variant="listbox" searchable>withflux:select.option+flux:select.option.createemitted from an@includeand from a nested component.FolderTest: unfoldable at template root with unresolvable@aware; still folds when the prop is passed directly.UnblazeTest: fold succeeds when the temp compiled file was cached by a previous process (fails on main with the reporter's exactUnblaze.php:87error).Full suite: 220 passed (including flux + flux-pro comparison suites run locally).
🤖 Generated with Claude Code