66#include " StyleFunction.hpp"
77#include " Specificity.hpp"
88#include " StyleResolver.hpp"
9+ #include " VariableContext.hpp"
910
1011#include < regex>
1112#include < variant>
@@ -65,9 +66,13 @@ namespace margelo::nitro::cssnitro {
6566
6667 const std::vector<HybridStyleRule> &styleRules = get (*styleIt->second );
6768
68- // Add all style rules to the collection
69- allStyleRules.insert (allStyleRules.end (), styleRules.begin (),
70- styleRules.end ());
69+ // Add only style rules that pass the test
70+ for (const HybridStyleRule &styleRule: styleRules) {
71+ if (Rules::testRule (styleRule, get, componentId, containerScope,
72+ validAttributeQueries)) {
73+ allStyleRules.push_back (styleRule);
74+ }
75+ }
7176 }
7277
7378 // Sort all style rules by specificity (highest specificity first)
@@ -76,14 +81,19 @@ namespace margelo::nitro::cssnitro {
7681 return Specificity::sort (a.s , b.s );
7782 });
7883
79- // Now process the sorted style rules
84+ // Process the inline variables
8085 for (const HybridStyleRule &styleRule: allStyleRules) {
81- // Skip rule if its conditions are not valid
82- if (!Rules::testRule (styleRule, get, componentId, containerScope,
83- validAttributeQueries)) {
84- continue ;
86+ if (styleRule.v .has_value ()) {
87+ const auto &inlineVariables = styleRule.v .value ();
88+ for (const auto &kv: inlineVariables->getMap ()) {
89+ VariableContext::setVariable (variableScope, kv.first , kv.second );
90+ }
8591 }
8692
93+ }
94+
95+ // Process the declarations
96+ for (const HybridStyleRule &styleRule: allStyleRules) {
8797 if (styleRule.d .has_value ()) {
8898 const auto &declarations = styleRule.d .value ();
8999
0 commit comments