[LiveComponent] Return StimulusAttributes from live_action() so it can be spread in a Twig component tag#3533
Open
Amoifr wants to merge 1 commit into
Open
Conversation
Member
|
For 3.x, 2.x is not maintained anymore |
…n be spread in a Twig component tag
7ee58ef to
8315cba
Compare
Contributor
Author
|
Done, rebased onto |
Contributor
📊 Packages dist files size differenceThanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Today,
live_action()casts its return value to astring, which prevents it from being spread into a Twig component tag:stimulus_action()already returns aStimulusAttributesobject (which is both\Stringableand\IteratorAggregate), so the same call written against it does work. The asymmetry was pointed out by @squrious in the issue discussion.This PR aligns
live_action()withstimulus_action()by returning the sameStimulusAttributesobject directly. Existing usages remain unaffected because Twig calls__toString()automatically when rendering the value (e.g.<button {{ live_action('save') }}>), and the helper is marked@internalon the PHP side.The existing
LiveComponentRuntimeTest::testGetLiveActionis adapted to cast the value to string for the equality assertion and gains a newassertInstanceOfto lock the return type.