Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Fix ComponentAttributeBag merge behaviour #31932

Merged
merged 3 commits into from Mar 12, 2020

Conversation

@mfullbrook
Copy link
Contributor

mfullbrook commented Mar 12, 2020

This PR is to fix the bug I raised in #31898. Below is an illustration of what this PR fixes.

With a component that defines some default attributes:

<table {{ $attributes->merge(['width' => '600', 'class' => 'mb-4']) }}>
  ...
</table>

If the component is used like this

<x-my-table width="100%" class="mt-2" />

We would expect the rendered template to be:

<table class="mb-4 mt-2" width="100%">
  ...
</table>

But the current implementation renders:

<table class="mb-4 mt-2" width="600">>
  ...
</table>

This PR fixes the implementation of ComponentAttributeBag::merge() so that it doesn't ignore attribute values specified in the template that is calling the component.

ViewComponentAttributeBagTest has been updated.

@GrahamCampbell GrahamCampbell changed the title [7.x]ComponentAttributeBag - merge() behaviour [7.x] Fix ComponentAttributeBag merge behaviour Mar 12, 2020
@taylorotwell taylorotwell merged commit 370b136 into laravel:7.x Mar 12, 2020
7 checks passed
7 checks passed
P7.2 - Sprefer-lowest
Details
P7.2 - Sprefer-stable
Details
P7.3 - Sprefer-lowest
Details
P7.3 - Sprefer-stable
Details
P7.4 - Sprefer-lowest
Details
P7.4 - Sprefer-stable
Details
continuous-integration/styleci/pr The analysis has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.