[8.x] Properly Inherit Parent Attributes #32576
Merged
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.
Imagine you have two components:
button
anddanger-button
, wheredanger-button
contains an instance ofbutton
with some additional classes. You are not able to proxy down any custom attributes to thebutton
component using$attributes
. For example, this will not work:This also will not work as expected since the
button
component will end up with an attribute namedattribute
:This PR fixes this behavior by detecting any bound attribute bags and merging any other classes with them before setting them as the parent's attribute bag. So, the syntax above using
:attributes="$attributes"
will be handled properly.It would be possible to handle the
{{ $attributes }}
passing syntax using some regular expressions to translate that syntax to:attributes="$attributes"
for custom Blade tags but will leave that to someone with more regular expression knowledge.Sending this to
master
since developers may already be working around this in more cumbersome ways that would be broken by this PR.