Skip to content

Commit 199193a

Browse files
authored
Revert PR 50403 (#50482)
1 parent 40c32ce commit 199193a

File tree

4 files changed

+45
-84
lines changed

4 files changed

+45
-84
lines changed

src/Illuminate/View/Compilers/ComponentTagCompiler.php

+2-31
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ protected function componentString(string $component, array $attributes)
258258
$parameters = $data->all();
259259
}
260260

261-
return "##BEGIN-COMPONENT-CLASS##@component('{$class}', '{$component}', \$componentData = [".$this->attributesToString($parameters, $escapeBound = false).'])
261+
return "##BEGIN-COMPONENT-CLASS##@component('{$class}', '{$component}', [".$this->attributesToString($parameters, $escapeBound = false).'])
262262
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass('.$class.'::class))->getConstructor()): ?>
263263
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
264264
<?php endif; ?>
265-
<?php $component->withAttributes(['.$this->attributesToStringWithExistingComponentData($attributes->all(), $escapeAttributes = $class !== DynamicComponent::class && ! is_subclass_of($class, DynamicComponent::class)).']); ?>';
265+
<?php $component->withAttributes(['.$this->attributesToString($attributes->all(), $escapeAttributes = $class !== DynamicComponent::class).']); ?>';
266266
}
267267

268268
/**
@@ -783,35 +783,6 @@ protected function attributesToString(array $attributes, $escapeBound = true)
783783
->implode(',');
784784
}
785785

786-
/**
787-
* Convert an array of attributes to a string using existing component data that has already been evaluated.
788-
*
789-
* @param array $attributes
790-
* @param bool $escapeBound
791-
* @return string
792-
*/
793-
protected function attributesToStringWithExistingComponentData(array $attributes, $escapeBound = true)
794-
{
795-
$results = [];
796-
797-
foreach ($attributes as $attribute => $value) {
798-
if (! $escapeBound ||
799-
! isset($this->boundAttributes[$attribute]) ||
800-
$value === 'true' ||
801-
is_numeric($value)) {
802-
$results[] = "'{$attribute}' => {$value}";
803-
804-
continue;
805-
}
806-
807-
$results[] = "'{$attribute}' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(".(
808-
($attribute === 'attributes') ? $value : ('$componentData[\'data\'][\''.Str::camel($attribute).'\'] ?? null')
809-
).')';
810-
}
811-
812-
return implode(',', $results);
813-
}
814-
815786
/**
816787
* Strip any quotes from the given string.
817788
*

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

-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public static function compileClassComponentOpening(string $component, string $a
6767
{
6868
return implode("\n", [
6969
'<?php if (isset($component)) { $__componentOriginal'.$hash.' = $component; } ?>',
70-
'<?php if (isset($componentData)) { $__componentDataOriginal'.$hash.' = $componentData; } ?>',
7170
'<?php if (isset($attributes)) { $__attributesOriginal'.$hash.' = $attributes; } ?>',
7271
'<?php $component = '.$component.'::resolve('.($data ?: '[]').' + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>',
7372
'<?php $component->withName('.$alias.'); ?>',
@@ -101,10 +100,6 @@ public function compileEndComponentClass()
101100
'<?php $attributes = $__attributesOriginal'.$hash.'; ?>',
102101
'<?php unset($__attributesOriginal'.$hash.'); ?>',
103102
'<?php endif; ?>',
104-
'<?php if (isset($__componentDataOriginal'.$hash.')): ?>',
105-
'<?php $componentData = $__componentDataOriginal'.$hash.'; ?>',
106-
'<?php unset($__componentDataOriginal'.$hash.'); ?>',
107-
'<?php endif; ?>',
108103
'<?php if (isset($__componentOriginal'.$hash.')): ?>',
109104
'<?php $component = $__componentOriginal'.$hash.'; ?>',
110105
'<?php unset($__componentOriginal'.$hash.'); ?>',

0 commit comments

Comments
 (0)