Skip to content

Commit 7f5d349

Browse files
[9.x] Fix components view error when using $attributes in parent view (#44778)
* [9.x] Fix components view error when using in parent view * [9.x] Fix components view error when using in parent view
1 parent 39d8502 commit 7f5d349

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed

src/Illuminate/View/Compilers/ComponentTagCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ protected function componentString(string $component, array $attributes)
251251
}
252252

253253
return "##BEGIN-COMPONENT-CLASS##@component('{$class}', '{$component}', [".$this->attributesToString($parameters, $escapeBound = false).'])
254-
<?php if (isset($attributes) && $constructor = (new ReflectionClass('.$class.'::class))->getConstructor()): ?>
254+
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass('.$class.'::class))->getConstructor()): ?>
255255
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
256256
<?php endif; ?>
257257
<?php $component->withAttributes(['.$this->attributesToString($attributes->all(), $escapeAttributes = $class !== DynamicComponent::class).']); ?>';

src/Illuminate/View/Compilers/Concerns/CompilesComponents.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static function compileClassComponentOpening(string $component, string $a
6464
{
6565
return implode("\n", [
6666
'<?php if (isset($component)) { $__componentOriginal'.$hash.' = $component; } ?>',
67-
'<?php $component = '.$component.'::resolve('.($data ?: '[]').' + (isset($attributes) ? (array) $attributes->getIterator() : [])); ?>',
67+
'<?php $component = '.$component.'::resolve('.($data ?: '[]').' + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>',
6868
'<?php $component->withName('.$alias.'); ?>',
6969
'<?php if ($component->shouldRender()): ?>',
7070
'<?php $__env->startComponent($component->resolveView(), $component->data()); ?>',

0 commit comments

Comments
 (0)