Skip to content

Using @aware does not remove attributes from $attributes #54276

@adwiv

Description

@adwiv

Laravel Version

11.37.0

PHP Version

8.2.15

Database Driver & Version

MariaDB 10.11.1 on macOS Intel

Description

When defining an anonymous component with parent accessor using @aware directive, we can override the parent attribute by passing the value in child component.

However, that attribute is not removed from the $attributes list.

Ideally, all attributes defined in the @aware directive should be removed from $attributes alongwith the attributes defined in @props

Steps To Reproduce

Using the example from Documentation - Blade#accessing-parent-data

This code:

<x-menu color="purple">
  <x-menu.item>...</x-menu.item>
  <x-menu.item color="red">...</x-menu.item>
</x-menu>

generates the following html (formatted for clarity)

<ul class="bg-purple-200">
    <li class="text-purple-800">...</li>
    <li class="text-red-800" color="red">...</li>
</ul>

As we can see, color="red" remains in the attribute list for second list item.

Only way to remove it from the attribute list is to define @props directive along with @aware, which seems redundant.

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