@@ -68,7 +68,7 @@ public static function compileClassComponentOpening(string $component, string $a
6868 return implode ("\n" , [
6969 '<?php if (isset($component)) { $__componentOriginal ' .$ hash .' = $component; } ?> ' ,
7070 '<?php if (isset($attributes)) { $__attributesOriginal ' .$ hash .' = $attributes; } ?> ' ,
71- '<?php $component = ' .$ component .'::resolve( ' .($ data ?: '[] ' ).' + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator () : [])); ?> ' ,
71+ '<?php $component = ' .$ component .'::resolve( ' .($ data ?: '[] ' ).' + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all () : [])); ?> ' ,
7272 '<?php $component->withName( ' .$ alias .'); ?> ' ,
7373 '<?php if ($component->shouldRender()): ?> ' ,
7474 '<?php $__env->startComponent($component->resolveView(), $component->data()); ?> ' ,
@@ -157,19 +157,41 @@ protected function compileEndComponentFirst()
157157 */
158158 protected function compileProps ($ expression )
159159 {
160- return "<?php \$attributes ??= new \\Illuminate \\View \\ComponentAttributeBag; ?>
161- <?php foreach( \$attributes->onlyProps {$ expression } as \$__key => \$__value) {
162- \$\$__key = \$\$__key ?? \$__value;
163- } ?>
164- <?php \$attributes = \$attributes->exceptProps {$ expression }; ?>
165- <?php foreach (array_filter( {$ expression }, 'is_string', ARRAY_FILTER_USE_KEY) as \$__key => \$__value) {
160+ return "<?php
161+ \$attributes ??= new \\Illuminate \\View \\ComponentAttributeBag;
162+
163+ \$__newAttributes = [];
164+
165+ \$__propNames = \Illuminate\Support\Arr::extractPropNames([
166+ 'class',
167+ 'name',
168+ 'id' => -1,
169+ ]);
170+
171+ foreach ( \$attributes->all() as \$__key => \$__value) {
172+ if (in_array( \$__key, \$__propNames)) {
173+ \$\$__key = \$__key ?? \$__value;
174+ } else {
175+ \$__newAttributes[ \$__key] = \$__value;
176+ }
177+ }
178+
179+ \$attributes = new \Illuminate\View\ComponentAttributeBag( \$__newAttributes);
180+
181+ unset( \$__propNames);
182+ unset( \$__newAttributes);
183+
184+ foreach (array_filter( {$ expression }, 'is_string', ARRAY_FILTER_USE_KEY) as \$__key => \$__value) {
166185 \$\$__key = \$\$__key ?? \$__value;
167- } ?>
168- <?php \$__defined_vars = get_defined_vars(); ?>
169- <?php foreach ( \$attributes as \$__key => \$__value) {
186+ }
187+
188+ \$__defined_vars = get_defined_vars();
189+
190+ foreach ( \$attributes as \$__key => \$__value) {
170191 if (array_key_exists( \$__key, \$__defined_vars)) unset( \$\$__key);
171- } ?>
172- <?php unset( \$__defined_vars); ?> " ;
192+ }
193+
194+ unset( \$__defined_vars); ?> " ;
173195 }
174196
175197 /**
0 commit comments