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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants