File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1212namespace Symfony \UX \TwigComponent ;
1313
1414use Symfony \UX \LiveComponent \Attribute \LiveProp ;
15+ use Symfony \UX \TwigComponent \Attribute \PostMount ;
1516use Symfony \UX \TwigComponent \Attribute \PreMount ;
1617
1718/**
@@ -25,13 +26,26 @@ trait HasAttributesTrait
2526 public ComponentAttributes $ attributes ;
2627
2728 #[PreMount]
28- public function mapAttributes (array $ data ): array
29+ public function preMountAttributes (array $ data ): array
2930 {
30- $ data ['attributes ' ] = new ComponentAttributes ($ data ['attributes ' ] ?? []);
31+ $ data ['_attributes ' ] = $ data ['attributes ' ] ?? [];
32+
33+ unset($ data ['attributes ' ]);
3134
3235 return $ data ;
3336 }
3437
38+ #[PostMount]
39+ public function mountAttributes (array $ data ): array
40+ {
41+ $ attributes = array_merge ($ data ['_attributes ' ], $ data );
42+ unset($ attributes ['_attributes ' ]);
43+
44+ $ this ->attributes = new ComponentAttributes ($ attributes );
45+
46+ return [];
47+ }
48+
3549 public static function dehydrateAttributes (ComponentAttributes $ attributes ): array
3650 {
3751 return $ attributes ->all ();
You can’t perform that action at this time.
0 commit comments