Skip to content

Commit 7d40721

Browse files
code (#51007)
1 parent 3da39ec commit 7d40721

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Illuminate/View/ComponentAttributeBag.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,7 @@ public function __toString()
502502
}
503503

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

509508
$string .= ' '.$key.'="'.str_replace('"', '\\"', trim($value)).'"';

tests/View/ViewComponentAttributeBagTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ public function testItMakesAnExceptionForAlpineXdata()
113113
$this->assertSame('required="required" x-data=""', (string) $bag);
114114
}
115115

116+
public function testItMakesAnExceptionForLivewireWireAttributes()
117+
{
118+
$bag = new ComponentAttributeBag([
119+
'wire:loading' => true,
120+
'wire:loading.remove' => true,
121+
'wire:poll' => true,
122+
]);
123+
124+
$this->assertSame('wire:loading="" wire:loading.remove="" wire:poll=""', (string) $bag);
125+
}
126+
116127
public function testAttributeExistence()
117128
{
118129
$bag = new ComponentAttributeBag(['name' => 'test']);

0 commit comments

Comments
 (0)