File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change 1313
1414use Symfony \UX \LiveComponent \Attribute \LiveProp ;
1515use Symfony \UX \TwigComponent \Attribute \PostMount ;
16- use Symfony \UX \TwigComponent \Attribute \PreMount ;
1716
1817/**
1918 * @author Kevin Bond <[email protected] > @@ -25,23 +24,19 @@ trait HasAttributesTrait
2524 #[LiveProp(hydrateWith: 'hydrateAttributes ' , dehydrateWith: 'dehydrateAttributes ' )]
2625 public ComponentAttributes $ attributes ;
2726
28- #[PreMount]
29- public function preMountAttributes (array $ data ): array
27+ public function setAttributes (array $ attributes ): void
3028 {
31- $ data ['_attributes ' ] = $ data ['attributes ' ] ?? [];
32-
33- unset($ data ['attributes ' ]);
34-
35- return $ data ;
29+ $ this ->attributes = new ComponentAttributes ($ attributes );
3630 }
3731
3832 #[PostMount(priority: -1000 )]
3933 public function mountAttributes (array $ data ): array
4034 {
41- $ attributes = array_merge ($ data ['_attributes ' ], $ data );
42- unset($ attributes ['_attributes ' ]);
35+ if (isset ($ this ->attributes )) {
36+ $ data = array_merge ($ this ->attributes ->all (), $ data );
37+ }
4338
44- $ this ->attributes = new ComponentAttributes ($ attributes );
39+ $ this ->attributes = new ComponentAttributes ($ data );
4540
4641 return [];
4742 }
You can’t perform that action at this time.
0 commit comments