Preserve literal static attributes when folding#185
Open
joshhanley wants to merge 1 commit into
Open
Conversation
3 tasks
Contributor
Benchmark Result: Default
Median of 10 attempts, 5000 iterations x 10 rounds, 45.56s 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.
The Scenario
A user has a Flux radio group bound to a nullable boolean property using Livewire's
.booleanmodifier. Without Blaze, selecting thefalseradio option updates the property tofalseas expected. With Blaze enabled, selecting thefalseoption still behaves as truthy, so the property appears to always betrue.The Problem
Blaze folding resolves static attribute values through
Attribute::getStaticValue()before rendering folded output. That method was converting any statictrue,false, ornullstring into the equivalent PHP value, even when the attribute was not bound.That meant
value="false"became booleanfalseduring folded rendering and was omitted by the attribute bag. Flux radio elements generate a fallback value when novalueattribute is present, so thefalseoption ended up with a generated non-empty string instead of"false".Meanwhile,
value="true"became booleantrueand rendered asvalue="value". Livewire's.booleanmodifier therefore received non-empty strings for both options, causing thefalseoption to behave as truthy.The Solution
This changes folded static attribute resolution so unbound literal values are kept as strings instead of being treated as PHP constants. Now
value="false"stays"false"during folding and renders the same way it does in Blade.Fixes livewire/flux#2651