Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix x-transition attribute handling in Blade components #54466

Open
wants to merge 2 commits into
base: 11.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions tests/View/Blade/BladeComponentTagCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ public function testClassNamesCanBeGuessed()
{
$container = new Container;
$container->instance(Application::class, $app = m::mock(Application::class));
$container->instance(Factory::class, $factory = m::mock(Factory::class));
$app->shouldReceive('getNamespace')->once()->andReturn('App\\');
Container::setInstance($container);

Expand All @@ -392,6 +393,7 @@ public function testClassNamesCanBeGuessedWithNamespaces()
{
$container = new Container;
$container->instance(Application::class, $app = m::mock(Application::class));
$container->instance(Factory::class, $factory = m::mock(Factory::class));
$app->shouldReceive('getNamespace')->once()->andReturn('App\\');
Container::setInstance($container);

Expand Down Expand Up @@ -570,8 +572,8 @@ public function testPackagesClasslessComponents()
$container = new Container;
$container->instance(Application::class, $app = m::mock(Application::class));
$container->instance(Factory::class, $factory = m::mock(Factory::class));
$app->shouldReceive('getNamespace')->andReturn('App\\');
$factory->shouldReceive('exists')->andReturn(true);
$app->shouldReceive('getNamespace')->once()->andReturn('App\\');
$factory->shouldReceive('exists')->once()->andReturn(true);
Container::setInstance($container);

$result = $this->compiler()->compileTags('<x-package::anonymous-component :name="\'Taylor\'" :age="31" wire:model="foo" />');
Expand Down Expand Up @@ -915,6 +917,18 @@ public function testOriginalAttributesAreRestoredAfterRenderingChildComponentWit
$this->assertSame($attributes->get('other'), 'ok');
}

public function testTransitionAttributeIsHandledCorrectly()
{
$this->mockViewFactory();
$result = $this->compiler(['test' => TestTransitionComponent::class])
->compileTags('<x-test x-transition>content</x-test>');

$this->assertStringContainsString(
"'x-transition' => true",
$result
);
}

protected function mockViewFactory($existsSucceeds = true)
{
$container = new Container;
Expand Down
13 changes: 13 additions & 0 deletions tests/View/Blade/Components/TestTransitionComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Illuminate\Tests\View\Blade\Components;

use Illuminate\View\Component;

class TestTransitionComponent extends Component
{
public function render()
{
return '<div {{ $attributes }}>{{ $slot }}</div>';
}
}