about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-05 14:51:08 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-05 14:51:42 +0100
commit5a807b8b6dd7937db8cb04491aae8e873767a307 (patch)
tree469af3d34cd56db918c10c1039ec04d9c05d8fcc /src/css
parent7fdc3a423754c25c05e376f8a02b7438350ed6eb (diff)
downloadchawan-5a807b8b6dd7937db8cb04491aae8e873767a307.tar.gz
Fix parsing of empty combinator selectors
Diffstat (limited to 'src/css')
-rw-r--r--src/css/selectorparser.nim7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/css/selectorparser.nim b/src/css/selectorparser.nim
index 97c6f029..926606da 100644
--- a/src/css/selectorparser.nim
+++ b/src/css/selectorparser.nim
@@ -412,7 +412,12 @@ func parseSelectors*(cvals: seq[CSSComponentValue]): seq[ComplexSelector] = {.ca
     elif cval of CSSFunction:
       state.parseSelectorFunction(CSSFunction(cval))
   if state.combinator != nil:
-    state.selectors[^1].add(state.combinator)
+    if state.combinator.csels.len == 1:
+      if state.combinator.ct == DESCENDANT_COMBINATOR:
+        # otherwise it's an invalid combinator
+        state.selectors[^1].add(state.combinator.csels[0])
+    else:
+      state.selectors[^1].add(state.combinator)
     state.combinator = nil
   return state.selectors