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

Blade Component Attributes: Passing boolean-style (without value) attributes #50994

Closed
devajmeireles opened this issue Apr 10, 2024 · 1 comment

Comments

@devajmeireles
Copy link
Contributor

Laravel Version

11.3.0

PHP Version

8.3.4

Database Driver & Version

N/A

Description

In some cases, we need to pass an attribute to a component using boolean style, i.e. without setting a value (such as empty), as is the case with things like wire:poll. A few days ago I noticed this:

Using like this:

<x-loading wire:poll />

Generates this HTML:

<div ... wire:poll="wire:poll">

Instead of:

<div ... wire:poll>

Therefore, using things like wire:poll ends up generating: wire:poll="wire:poll" which ends up becoming a problem, even if a small one. There must certainly be several other cases where we need to pass attributes in this way, I'm just not remembering it now (besides, of course, things like required and disabled, where the value is optional)

Steps To Reproduce

  1. Create a dummy component
  2. Insert the {{ $attributes }} on this
  3. Use the component passing a component attribute like wire:poll
  4. Use your browser dev tools to check the final HTML generated: wire:poll="wire:poll"
@driesvints
Copy link
Member

Yeah, I can reproduce this. Looks like this isn't supported at this time, sorry. I suggest you add a boolean check within the component itself to dynamically enable this. We'd appreciate a PR to maybe escape attributes like this so they're unaltered.

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

No branches or pull requests

2 participants