@@ -74,14 +74,45 @@ namespace margelo::nitro::cssnitro {
7474 // Convert mergedStyles to AnyMap and set next.style
7575 if (!mergedStyles.empty ()) {
7676 auto anyMap = AnyMap::make (mergedStyles.size ());
77+
78+ static const std::unordered_set<std::string> transformProps = {
79+ " translateX" , " translateY" , " translateZ" ,
80+ " rotate" , " rotateX" , " rotateY" , " rotateZ" ,
81+ " scaleX" , " scaleY" , " scaleZ" ,
82+ " skewX" , " skewY" ,
83+ " perspective"
84+ };
85+
7786 for (const auto &kv: mergedStyles) {
78- if (kv.first == " rotate " ) {
87+ if (transformProps. count ( kv.first ) > 0 ) {
7988 if (!anyMap->contains (" transform" )) {
8089 anyMap->setArray (" transform" , AnyArray{});
8190 }
8291
83- const auto &transformArray = anyMap->getArray (" transform" );
84- // find the value in the array with the key "rotate" and set the key "rotate" to kv.second
92+ auto transformArray = anyMap->getArray (" transform" );
93+
94+ // find the value in the array with the key matching kv.first and set it to kv.second
95+ bool foundTransform = false ;
96+ for (auto &item: transformArray) {
97+ if (std::holds_alternative<AnyObject>(item)) {
98+ auto &obj = std::get<AnyObject>(item);
99+ if (obj.count (kv.first ) > 0 ) {
100+ obj[kv.first ] = kv.second ;
101+ foundTransform = true ;
102+ break ;
103+ }
104+ }
105+ }
106+
107+ // If transform property not found in array, add a new transform object
108+ if (!foundTransform) {
109+ AnyObject transformObj;
110+ transformObj[kv.first ] = kv.second ;
111+ transformArray.emplace_back (transformObj);
112+ }
113+
114+ anyMap->setArray (" transform" , transformArray);
115+ continue ;
85116 }
86117
87118 anyMap->setAny (kv.first , kv.second );
0 commit comments