diff --git a/src/Illuminate/View/Compilers/Concerns/CompilesComponents.php b/src/Illuminate/View/Compilers/Concerns/CompilesComponents.php index 706e1b393c40..db4f0e88abf6 100644 --- a/src/Illuminate/View/Compilers/Concerns/CompilesComponents.php +++ b/src/Illuminate/View/Compilers/Concerns/CompilesComponents.php @@ -78,15 +78,7 @@ public static function compileClassComponentOpening(string $component, string $a */ protected function compileEndComponent() { - $hash = array_pop(static::$componentHashStack); - - return implode("\n", [ - '', - '', - '', - '', - 'renderComponent(); ?>', - ]); + return 'renderComponent(); ?>'; } /** @@ -96,8 +88,14 @@ protected function compileEndComponent() */ public function compileEndComponentClass() { + $hash = array_pop(static::$componentHashStack); + return $this->compileEndComponent()."\n".implode("\n", [ '', + '', + '', + '', + '', ]); } diff --git a/tests/View/Blade/BladeComponentsTest.php b/tests/View/Blade/BladeComponentsTest.php index 8f7925f3e6d0..83c5d2bfe6fd 100644 --- a/tests/View/Blade/BladeComponentsTest.php +++ b/tests/View/Blade/BladeComponentsTest.php @@ -23,22 +23,18 @@ public function testEndComponentsAreCompiled() { $this->compiler->newComponentHash('foo'); - $this->assertSame(' - - - -renderComponent(); ?>', $this->compiler->compileString('@endcomponent')); + $this->assertSame('renderComponent(); ?>', $this->compiler->compileString('@endcomponent')); } public function testEndComponentClassesAreCompiled() { $this->compiler->newComponentHash('foo'); - $this->assertSame(' + $this->assertSame('renderComponent(); ?> + + - -renderComponent(); ?> ', $this->compiler->compileString('@endcomponentClass')); }