Skip to content

Commit

Permalink
fix dynamic component bug
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 9, 2020
1 parent 75e792d commit 4b1e317
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/View/DynamicComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(string $component)
public function render()
{
$template = <<<'EOF'
<?php extract(collect($attributes->getAttributes())->mapWithKeys(function ($value, $key) { return [Illuminate\Support\Str::camel($key) => $value]; })->all(), EXTR_SKIP); ?>
<?php extract(collect($attributes->getAttributes())->mapWithKeys(function ($value, $key) { return [Illuminate\Support\Str::camel(str_replace(':', ' ', $key)) => $value]; })->all(), EXTR_SKIP); ?>
{{ props }}
<x-{{ component }} {{ bindings }} {{ attributes }}>
{{ slots }}
Expand Down Expand Up @@ -113,7 +113,7 @@ protected function compileProps(array $bindings)
protected function compileBindings(array $bindings)
{
return collect($bindings)->map(function ($key) {
return ':'.$key.'="$'.Str::camel($key).'"';
return ':'.$key.'="$'.Str::camel(str_replace(':', ' ', $key)).'"';
})->implode(' ');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/View/BladeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function test_rendering_a_dynamic_component()
{
$view = View::make('uses-panel-dynamically', ['name' => 'Taylor'])->render();

$this->assertEquals('<div class="ml-2">
$this->assertEquals('<div class="ml-2" wire:model="foo">
Hello Taylor
</div>', trim($view));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<x-dynamic-component component="panel" class="ml-2" :name="$name">
<x-dynamic-component component="panel" class="ml-2" :name="$name" wire:model="foo">
Panel contents
</x-dynamic-component>

0 comments on commit 4b1e317

Please sign in to comment.