about summary refs log tree commit diff stats
path: root/src/css/select.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-01-23 15:20:56 +0100
committerbptato <nincsnevem662@gmail.com>2022-01-23 15:20:56 +0100
commit9dc1c7da62ff00fc8f9796f570902daefd7341af (patch)
tree469604c81e671ca0ce5b090de26302ccf94b3ce5 /src/css/select.nim
parentfb1d193045a6e1144e33711646c9b1d49e2781af (diff)
downloadchawan-9dc1c7da62ff00fc8f9796f570902daefd7341af.tar.gz
Fix some block box bugs
Diffstat (limited to 'src/css/select.nim')
-rw-r--r--src/css/select.nim11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/css/select.nim b/src/css/select.nim
index 3a2e0e27..1bd45dcd 100644
--- a/src/css/select.nim
+++ b/src/css/select.nim
@@ -32,15 +32,12 @@ func attrSelectorMatches(elem: Element, sel: Selector): bool =
   of '*': return elem.attr(sel.attr).contains(sel.value)
   else: return false
 
-func pseudoElemSelectorMatches(elem: Element, s: string): SelectResult =
-  case s
+func pseudoElemSelectorMatches(elem: Element, sel: Selector): SelectResult =
+  case sel.elem
   of "before": return selectres(true, PSEUDO_BEFORE)
   of "after": return selectres(true, PSEUDO_AFTER)
   else: return selectres(false)
 
-func pseudoElemSelectorMatches(elem: Element, sel: Selector): SelectResult =
-  return elem.pseudoElemSelectorMatches(sel.elem)
-
 func pseudoSelectorMatches(elem: Element, sel: Selector): SelectResult =
   case sel.pseudo
   of "first-child": return selectres(elem.parentNode.firstElementChild == elem)
@@ -48,7 +45,9 @@ func pseudoSelectorMatches(elem: Element, sel: Selector): SelectResult =
   of "only-child": return selectres(elem.parentNode.firstElementChild == elem and elem.parentNode.lastElementChild == elem)
   of "hover": return selectres(elem.hover)
   of "root": return selectres(elem == elem.ownerDocument.root)
-  else: return elem.pseudoElemSelectorMatches(sel.pseudo)
+  of "before": return selectres(true, PSEUDO_BEFORE)
+  of "after": return selectres(true, PSEUDO_AFTER)
+  else: return selectres(false)
 
 func selectorsMatch*(elem: Element, selectors: SelectorList): SelectResult