Repository navigation
[13.x] Render bound attributes of dynamic class components like the component tag - #62455
Merged
Merged
Conversation
…t tag Amp-Thread-ID: https://ampcode.com/threads/T-0533443c-7960-4b84-ac43-da79addb1552 Co-authored-by: Pushpak Chhajed <pushpak@laravel.com>
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.
<x-dynamic-component>renders bound attributes differently from the component tag it stands in for when the target is a class component:The dynamic component tag compiles its attributes without encoding them, so that anonymous targets don't encode them twice (#34346). Class targets receive those attributes through
{{ $attributes }}, which doesn't encode them again, so bound values that aren't constructor parameters reach the HTML as they are.The compiler now passes the names of the bound attributes to
DynamicComponent. When the target is a class,DynamicComponentappliesBladeCompiler::sanitizeComponentAttribute()to those values before they are merged into the attribute bag, which is what the component tag does. As a result::title="$title"<x-alert>title="{{ $title }}",title="static"HtmlString, models, collections{{ $attributes }}The test renders each form through
<x-dynamic-component>and through the component tag and asserts that the output is identical.Note
Compiled views keep the previous behavior until they are recompiled with
php artisan view:clearorphp artisan view:cache.