Skip to content

Extra attributes are added to html element #52663

@vascocarreira

Description

@vascocarreira

Laravel Version

11.22

PHP Version

8.3.11

Database Driver & Version

No response

Description

All attributes are added when attributes merge is invoked

Steps To Reproduce

According to Laravel's documentation in https://laravel.com/docs/11.x/blade#default-merged-attributes, if the attributes in a blade component are set like this:
<div {{ $attributes->merge(['class' => 'alert alert-'.$type]) }}>
{{ $message }}
</div>

And then we invoke the component like this:
<x-alert type="error" :message="$message" class="mb-4"/>

The end result should be this:
<div class="alert alert-error mb-4">
<!-- Contents of the $message variable -->
</div>

But... That's not what I'm getting.
All attributes passed in the blade component are being added to the html element where I'm calling the attributes merge.
Please, check the following screenshot.

Screenshot from 2024-09-05 18-42-44

Am I doing something wrong or missing something?
Or is this a real issue?

Thanks in advance.
Regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions