Skip to content

Commit

Permalink
code (#51007)
Browse files Browse the repository at this point in the history
  • Loading branch information
devajmeireles authored Apr 10, 2024
1 parent 3da39ec commit 7d40721
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Illuminate/View/ComponentAttributeBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,7 @@ public function __toString()
}

if ($value === true) {
// Exception for Alpine...
$value = $key === 'x-data' ? '' : $key;
$value = $key === 'x-data' || str_starts_with($key, 'wire:') ? '' : $key;
}

$string .= ' '.$key.'="'.str_replace('"', '\\"', trim($value)).'"';
Expand Down
11 changes: 11 additions & 0 deletions tests/View/ViewComponentAttributeBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ public function testItMakesAnExceptionForAlpineXdata()
$this->assertSame('required="required" x-data=""', (string) $bag);
}

public function testItMakesAnExceptionForLivewireWireAttributes()
{
$bag = new ComponentAttributeBag([
'wire:loading' => true,
'wire:loading.remove' => true,
'wire:poll' => true,
]);

$this->assertSame('wire:loading="" wire:loading.remove="" wire:poll=""', (string) $bag);
}

public function testAttributeExistence()
{
$bag = new ComponentAttributeBag(['name' => 'test']);
Expand Down

0 comments on commit 7d40721

Please sign in to comment.