From 821c0159c03a12686fb30fe0b035a78dde7c0664 Mon Sep 17 00:00:00 2001 From: AJ Meireles Date: Wed, 10 Apr 2024 14:35:34 -0300 Subject: [PATCH] code --- src/Illuminate/View/ComponentAttributeBag.php | 3 +-- tests/View/ViewComponentAttributeBagTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index 02f8c02e854e..368391c038ff 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -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)).'"'; diff --git a/tests/View/ViewComponentAttributeBagTest.php b/tests/View/ViewComponentAttributeBagTest.php index 1b64720f9b79..82fbd8687fa1 100644 --- a/tests/View/ViewComponentAttributeBagTest.php +++ b/tests/View/ViewComponentAttributeBagTest.php @@ -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']);