diff --git a/src/Illuminate/View/ComponentAttributeBag.php b/src/Illuminate/View/ComponentAttributeBag.php index cf61c2e3e5e7..7b713ce21afa 100644 --- a/src/Illuminate/View/ComponentAttributeBag.php +++ b/src/Illuminate/View/ComponentAttributeBag.php @@ -126,8 +126,8 @@ public function whereStartsWith($string) */ public function whereDoesntStartWith($string) { - return $this->reject(function ($value, $key) use ($string) { - return Str::startsWith($key, $string); + return $this->filter(function ($value, $key) use ($string) { + return ! Str::startsWith($key, $string); }); } diff --git a/tests/View/ViewComponentAttributeBagTest.php b/tests/View/ViewComponentAttributeBagTest.php index 65240cb914a9..c91e74589e24 100644 --- a/tests/View/ViewComponentAttributeBagTest.php +++ b/tests/View/ViewComponentAttributeBagTest.php @@ -13,6 +13,8 @@ public function testAttributeRetrieval() $this->assertSame('class="font-bold"', (string) $bag->whereStartsWith('class')); $this->assertSame('font-bold', (string) $bag->whereStartsWith('class')->first()); + $this->assertSame('name="test"', (string) $bag->whereDoesntStartWith('class')); + $this->assertSame('test', (string) $bag->whereDoesntStartWith('class')->first()); $this->assertSame('class="mt-4 font-bold" name="test"', (string) $bag->merge(['class' => 'mt-4'])); $this->assertSame('class="mt-4 font-bold" name="test"', (string) $bag->merge(['class' => 'mt-4', 'name' => 'foo'])); $this->assertSame('class="mt-4 font-bold" id="bar" name="test"', (string) $bag->merge(['class' => 'mt-4', 'id' => 'bar']));