Row

'; } } /** * A list whose rows each hold `$markup`, then a child component. Livewire keys a child from the * loop around it, and takes a `wire:key` written in any template rendered in the row for the row's * key: a component that wrote its own that way would key every row's child alike. */ class KeyedRowsProbe extends Component { public static string $markup = ''; public function render(): string { return '
@foreach ([1, 2] as $row)
'.static::$markup.'
@endforeach
'; } } it('keys what a morph must patch in place, without keying the child components after it', function (string $markup, string $key) { Livewire::component('keyed-row-child-probe', KeyedRowChildProbe::class); Livewire::component('keyed-rows-probe', KeyedRowsProbe::class); KeyedRowsProbe::$markup = $markup; $html = Livewire::test('keyed-rows-probe')->html(); preg_match_all('/]*\bwire:key="([^"]+)"[^>]*>Row<\/p>/', $html, $children); expect(substr_count($html, "wire:key=\"{$key}\""))->toBe(2) ->and($children[1])->toHaveCount(2) ->and(array_unique($children[1]))->toHaveCount(2); })->with([ 'menu' => ['', 'material-menu'], 'FAB menu' => ['', 'material-fab-menu'], 'rich tooltip' => ['', 'material-rich-tooltip'], 'carousel' => ['', 'material-carousel'], ]);