Skip to content

Commit 48d1c19

Browse files
authored
Add space after component closing tag (#32005)
1 parent ec7d5b8 commit 48d1c19

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/Illuminate/View/Compilers/ComponentTagCompiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected function compileSelfClosingTags(string $value)
149149

150150
$attributes = $this->getAttributesFromAttributeString($matches['attributes']);
151151

152-
return $this->componentString($matches[1], $attributes)."\n@endcomponentClass";
152+
return $this->componentString($matches[1], $attributes)."\n@endcomponentClass ";
153153
}, $value);
154154
}
155155

@@ -270,7 +270,7 @@ protected function partitionDataAndAttributes($class, array $attributes)
270270
*/
271271
protected function compileClosingTags(string $value)
272272
{
273-
return preg_replace("/<\/\s*x[-\:][\w\-\:\.]*\s*>/", ' @endcomponentClass', $value);
273+
return preg_replace("/<\/\s*x[-\:][\w\-\:\.]*\s*>/", ' @endcomponentClass ', $value);
274274
}
275275

276276
/**

tests/View/Blade/BladeComponentTagCompilerTest.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public function testBasicComponentParsing()
3131

3232
$this->assertSame("<div> @component('Illuminate\Tests\View\Blade\TestAlertComponent', [])
3333
<?php \$component->withAttributes(['type' => 'foo','limit' => '5','@click' => 'foo','required' => true]); ?>
34-
@endcomponentClass @component('Illuminate\Tests\View\Blade\TestAlertComponent', [])
34+
@endcomponentClass @component('Illuminate\Tests\View\Blade\TestAlertComponent', [])
3535
<?php \$component->withAttributes([]); ?>
36-
@endcomponentClass</div>", trim($result));
36+
@endcomponentClass </div>", trim($result));
3737
}
3838

3939
public function testBasicComponentWithEmptyAttributesParsing()
@@ -42,7 +42,7 @@ public function testBasicComponentWithEmptyAttributesParsing()
4242

4343
$this->assertSame("<div> @component('Illuminate\Tests\View\Blade\TestAlertComponent', [])
4444
<?php \$component->withAttributes(['type' => '','limit' => '','@click' => '','required' => true]); ?>
45-
@endcomponentClass</div>", trim($result));
45+
@endcomponentClass </div>", trim($result));
4646
}
4747

4848
public function testDataCamelCasing()
@@ -91,7 +91,7 @@ public function testSelfClosingComponentsCanBeCompiled()
9191

9292
$this->assertSame("<div> @component('Illuminate\Tests\View\Blade\TestAlertComponent', [])
9393
<?php \$component->withAttributes([]); ?>
94-
@endcomponentClass</div>", trim($result));
94+
@endcomponentClass </div>", trim($result));
9595
}
9696

9797
public function testClassNamesCanBeGuessed()
@@ -140,6 +140,23 @@ public function testSelfClosingComponentsCanBeCompiledWithDataAndAttributes()
140140
@endcomponentClass", trim($result));
141141
}
142142

143+
public function testComponentsCanHaveAttachedWord()
144+
{
145+
$result = (new ComponentTagCompiler(['profile' => TestProfileComponent::class]))->compileTags('<x-profile></x-profile>Words');
146+
147+
$this->assertSame("@component('Illuminate\Tests\View\Blade\TestProfileComponent', [])
148+
<?php \$component->withAttributes([]); ?> @endcomponentClass Words", trim($result));
149+
}
150+
151+
public function testSelfClosingComponentsCanHaveAttachedWord()
152+
{
153+
$result = (new ComponentTagCompiler(['alert' => TestAlertComponent::class]))->compileTags('<x-alert/>Words');
154+
155+
$this->assertSame("@component('Illuminate\Tests\View\Blade\TestAlertComponent', [])
156+
<?php \$component->withAttributes([]); ?>
157+
@endcomponentClass Words", trim($result));
158+
}
159+
143160
public function testSelfClosingComponentsCanBeCompiledWithBoundData()
144161
{
145162
$result = (new ComponentTagCompiler(['alert' => TestAlertComponent::class]))->compileTags('<x-alert :title="$title" class="bar" />');

0 commit comments

Comments
 (0)