aboutsummaryrefslogtreecommitdiffstats
path: root/src/css/selectorparser.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-12-17 18:41:49 +0100
committerbptato <nincsnevem662@gmail.com>2024-12-17 18:41:49 +0100
commit340042ea464c7b9e0eec6ff7ffb7839eb927ad62 (patch)
treef30bf68edc9492e52a605b6bdf8fb2b63cad5828 /src/css/selectorparser.nim
parent60d22e5c6106ef36202bdfa236a6461a2561dacd (diff)
downloadchawan-340042ea464c7b9e0eec6ff7ffb7839eb927ad62.tar.gz
dom, match: optimize :nth-child, :nth-last-child
I want to use it in the UA sheet, so the loop won't cut it. (Also fix a parsing bug that prevented "of" from working.)
Diffstat (limited to 'src/css/selectorparser.nim')
-rw-r--r--src/css/selectorparser.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/css/selectorparser.nim b/src/css/selectorparser.nim
index 33302068..4330bd18 100644
--- a/src/css/selectorparser.nim
+++ b/src/css/selectorparser.nim
@@ -304,6 +304,9 @@ proc parseNthChild(state: var SelectorParser; cssfunction: CSSFunction;
let lasttok = get_tok cssfunction.value[i]
if lasttok.t != cttIdent or not lasttok.value.equalsIgnoreCase("of"):
fail
+ inc i
+ while i < cssfunction.value.len and cssfunction.value[i] == cttWhitespace:
+ inc i
if i == cssfunction.value.len: fail
nthchild.pseudo.ofsels = cssfunction.value[i..^1]
.parseSelectorList(state.factory, nested = true, forgiving = false)