Always abort fold when @aware prop is dynamic, regardless of safe list#181
Closed
joshhanley wants to merge 2 commits into
Closed
Always abort fold when @aware prop is dynamic, regardless of safe list#181joshhanley wants to merge 2 commits into
@aware prop is dynamic, regardless of safe list#181joshhanley wants to merge 2 commits into
Conversation
When an `@aware` prop is supplied dynamically by the parent, the fold must be aborted so the runtime `@aware` lookup survives. v1.0.12 added this guard, but routed the prop through the same `$unsafe` lookup that `safe:` subtracts from, so any prop listed in both was silently re-permitted and the fold proceeded. Short-circuit the aware-from-parent-dynamic case before it touches `safe:`/`$unsafe`. A `safe:` declaration is a promise about dynamic values passed on the component itself; it cannot apply to values that enter via `@aware`, because folding eliminates the `@aware` lookup entirely. Fixes livewire/flux#2613
Contributor
Benchmark Result: Default
Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 46.67s total To run a specific benchmark, comment |
Collaborator
|
The real problem here is that In this example from the test case it would be incorrect to mark Looking at the blaze directive in I’ll open a PR in flux. |
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.
The Scenario
A Flux user wraps
<flux:select>in an anonymous component that forwards a dynamic:indicator. They expect each<flux:select.option>to render a checkbox indicator whenmultipleis true. Instead, each option renders the default indicator. Replacing the dynamic value with a staticindicator="checkbox"works, so the bug only happens when:indicatoris supplied dynamically by the parent.The Problem
Flux's
select/option/index.blade.phplistsindicatorin both@awareandsafe::v1.0.12 added a guard so that an
@awareprop supplied dynamically by the parent aborts the fold. But the guard runs the prop through the same$unsafelookup thatsafe:subtracts from, so any prop listed in both is silently re-permitted and the fold proceeds. The@awareruntime lookup is then compiled away and the child renders with the prop's default.The Solution
Abort the fold immediately when an
@awareprop is supplied dynamically by the parent, without consultingsafe:. Asafe:declaration is a promise about dynamic values passed on the component itself; it cannot apply to values that enter via@aware, because folding eliminates the@awarelookup entirely.Fixes livewire/flux#2613