about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-28 22:17:58 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-28 22:17:58 +0100
commitc51d938392e04b0448a80ec61f5c9fd6fbb91564 (patch)
tree4a989c7dc7da47f734f2f86cd2780fbd4bd488db /src/css
parent2765d53eea53f23bf7686a6f39b81c04e741ae3a (diff)
downloadchawan-c51d938392e04b0448a80ec61f5c9fd6fbb91564.tar.gz
selectorparser: fix pseudo elements on combinator selectors
Diffstat (limited to 'src/css')
-rw-r--r--src/css/selectorparser.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/css/selectorparser.nim b/src/css/selectorparser.nim
index 2c6ab659..48bc8367 100644
--- a/src/css/selectorparser.nim
+++ b/src/css/selectorparser.nim
@@ -169,8 +169,11 @@ func getSpecificity*(sels: ComplexSelector): int =
     result += getSpecificity(sel)
 
 func pseudo*(sels: ComplexSelector): PseudoElem =
-  if sels.len > 0 and sels[^1].t == PSELEM_SELECTOR:
-    return sels[^1].elem
+  var sel = sels[^1]
+  while sel.t == COMBINATOR_SELECTOR:
+    sel = sel.csels[^1][^1]
+  if sel.t == PSELEM_SELECTOR:
+    return sel.elem
   return PSEUDO_NONE
 
 proc addSelector(state: var SelectorParser, sel: Selector) =