diff --git a/src/Compiler/Compiler.php b/src/Compiler/Compiler.php index 50614db..e2a0d4b 100644 --- a/src/Compiler/Compiler.php +++ b/src/Compiler/Compiler.php @@ -203,6 +203,7 @@ public static function compileClassComponentOpening(string $component, string $a { return implode("\n", [ '', + '', 'getIterator() : [])); ?>', 'withName('.$alias.'); ?>', 'shouldRender()): ?>', diff --git a/src/Compiler/Concerns/CompilesComponents.php b/src/Compiler/Concerns/CompilesComponents.php index 5b6bf00..348784f 100644 --- a/src/Compiler/Concerns/CompilesComponents.php +++ b/src/Compiler/Concerns/CompilesComponents.php @@ -43,6 +43,10 @@ public function compileEndComponentClass(): string $hash = array_pop(Compiler::$componentHashStack); return $this->compileEndComponent()."\n".implode("\n", [ + '', + '', + '', + '', '', '', '', diff --git a/tests/Compiler/BladeComponentTagCompilerTest.php b/tests/Compiler/BladeComponentTagCompilerTest.php index ec0d6a6..5942100 100644 --- a/tests/Compiler/BladeComponentTagCompilerTest.php +++ b/tests/Compiler/BladeComponentTagCompilerTest.php @@ -810,7 +810,7 @@ public function testAttributesTreatedAsPropsAreRemovedFromFinalAttributes() eval(" ?> $template assertNull($attributes->get('userId')); + $this->assertSame($attributes->get('userId'), 'bar'); $this->assertSame($attributes->get('other'), 'ok'); } diff --git a/tests/Compiler/BladeComponentsTest.php b/tests/Compiler/BladeComponentsTest.php index 45a88b5..26400de 100644 --- a/tests/Compiler/BladeComponentsTest.php +++ b/tests/Compiler/BladeComponentsTest.php @@ -18,6 +18,7 @@ public function testComponentsAreCompiled() public function testClassComponentsAreCompiled() { $this->assertSame(' + "bar"] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?> withName(\'test\'); ?> shouldRender()): ?> @@ -37,6 +38,10 @@ public function testEndComponentClassesAreCompiled() $this->assertSame('renderComponent(); ?> + + + +