@@ -28,7 +28,7 @@ namespace margelo::nitro::cssnitro {
2828 struct HybridStyleRegistry ::Impl {
2929 Impl ();
3030
31- void set (const std::string &className, const StyleRule &styleRule);
31+ void set (const std::string &className, const std::vector< StyleRule> &styleRule);
3232
3333 Declarations
3434 getDeclarations (const std::string &componentId, const std::string &classNames,
@@ -77,7 +77,7 @@ namespace margelo::nitro::cssnitro {
7777 private:
7878 std::unique_ptr<ShadowTreeUpdateManager> shadowUpdates_;
7979 std::unordered_map<std::string, std::shared_ptr<reactnativecss::Computed<Styled>>> computedMap_;
80- std::unordered_map<std::string, std::shared_ptr<reactnativecss::Observable<StyleRule>>> styleRuleMap_;
80+ std::unordered_map<std::string, std::shared_ptr<reactnativecss::Observable<std::vector< StyleRule> >>> styleRuleMap_;
8181 };
8282
8383
@@ -96,7 +96,8 @@ namespace margelo::nitro::cssnitro {
9696
9797 HybridStyleRegistry::~HybridStyleRegistry () = default ;
9898
99- void HybridStyleRegistry::set (const std::string &className, const StyleRule &styleRule) {
99+ void HybridStyleRegistry::set (const std::string &className,
100+ const std::vector<StyleRule> &styleRule) {
100101 impl_->set (className, styleRule);
101102 }
102103
@@ -168,10 +169,10 @@ namespace margelo::nitro::cssnitro {
168169 }
169170
170171 void HybridStyleRegistry::Impl::set (const std::string &className,
171- const StyleRule &styleRule) {
172+ const std::vector< StyleRule> &styleRule) {
172173 auto it = styleRuleMap_.find (className);
173174 if (it == styleRuleMap_.end ()) {
174- auto observable = reactnativecss::Observable<StyleRule>::create (styleRule);
175+ auto observable = reactnativecss::Observable<std::vector< StyleRule> >::create (styleRule);
175176 styleRuleMap_.emplace (className, std::move (observable));
176177 } else if (it->second ) {
177178 it->second ->set (styleRule);
@@ -202,8 +203,15 @@ namespace margelo::nitro::cssnitro {
202203 continue ;
203204 }
204205
205- const StyleRule &styleRule = styleIt->second ->get ();
206- if (styleRule.v .has_value ()) {
206+ const std::vector<StyleRule> &styleRules = styleIt->second ->get ();
207+ bool hasVars = false ;
208+ for (const auto &sr: styleRules) {
209+ if (sr.v .has_value ()) {
210+ hasVars = true ;
211+ break ;
212+ }
213+ }
214+ if (hasVars) {
207215 declarations.variableScope = componentId;
208216 break ;
209217 }
@@ -228,7 +236,9 @@ namespace margelo::nitro::cssnitro {
228236 (void ) rerender;
229237
230238 // Build computed Styled via factory
231- auto computed = makeStyledComputed (styleRuleMap_, classNames, componentId, *shadowUpdates_);
239+ auto computed = ::margelo::nitro::cssnitro::makeStyledComputed (styleRuleMap_, classNames,
240+ componentId,
241+ *shadowUpdates_);
232242
233243 computedMap_[componentId] = computed;
234244
0 commit comments