Skip to content

Commit

Permalink
Merge pull request #654 from cortex-engine/master
Browse files Browse the repository at this point in the history
CSS: Fix wildcard selector for hierarchical selector-parts
  • Loading branch information
ianharrigan authored Nov 18, 2024
2 parents db51e28 + 4a85dff commit 5039134
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions haxe/ui/styles/elements/RuleElement.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,24 @@ class RuleElement {
}

public function match(d:Component):Bool {
return ruleMatch(selector.parts[selector.parts.length - 1], d);
var res = 0;
for (s in selector.parts) {
res += ruleMatch(s, d) ? 1 : 0;
if (s.parent != null && d.parentComponent != null)
if (s.direct == true)
res += ruleMatch(s.parent, d.parentComponent) ? 1 : 0;
else {
var p = d.parentComponent;
while (p != null) {
if (ruleMatch(s.parent, p)) {
res++;
break;
}
p = p.parentComponent;
}
}
}
return res == selector.parts.length;
}

private static function ruleMatch( c : SelectorPart, d : Component ):Bool {
Expand Down Expand Up @@ -59,29 +76,6 @@ class RuleElement {
}
}

if (c.parent != null) {
if (c.direct == true) {
var p = d.parentComponent;
if (p == null) {
return false;
}
if (!ruleMatch(c.parent, p)) {
return false;
}
} else {
var p = d.parentComponent;
while (p != null) {
if (ruleMatch(c.parent, p)) {
break;
}
p = p.parentComponent;
}
if (p == null) {
return false;
}
}
}

return true;
}

Expand Down

0 comments on commit 5039134

Please sign in to comment.