diff options
author | bptato <nincsnevem662@gmail.com> | 2024-07-17 17:58:50 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-07-17 17:58:50 +0200 |
commit | c8d7a2a27720056fc60a5d67b56f515af4442cf4 (patch) | |
tree | 519bc2396104c6a3cbdf02d2b982b7ff3863ace2 /src/css | |
parent | cb2331f924ea17ff0c902a1843983861c2c19e92 (diff) | |
download | chawan-c8d7a2a27720056fc60a5d67b56f515af4442cf4.tar.gz |
dom, match, event: small cleanup
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/match.nim | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/css/match.nim b/src/css/match.nim index 02c921b9..567f00bb 100644 --- a/src/css/match.nim +++ b/src/css/match.nim @@ -63,7 +63,7 @@ func attrSelectorMatches(elem: Element; sel: Selector): bool = func selectorsMatch*[T: Element|StyledNode](elem: T; cxsel: ComplexSelector; felem: T = nil): bool -func selectorsMatch*[T: Element|StyledNode](elem: T; slist: SelectorList; +func selectorsMatch[T: Element|StyledNode](elem: T; slist: SelectorList; felem: T = nil): bool = for cxsel in slist: if elem.selectorsMatch(cxsel, felem): @@ -237,23 +237,23 @@ func complexSelectorMatches[T: Element|StyledNode](elem: T; #TODO make that an explicit flag or something, also get rid of the Element case func selectorsMatch*[T: Element|StyledNode](elem: T; cxsel: ComplexSelector; felem: T = nil): bool = - var felem = if felem != nil: + let felem = if felem != nil: felem else: elem return elem.complexSelectorMatches(cxsel, felem) -proc querySelectorAll(node: Node; q: string): seq[Element] = +# Forward declaration hack +doqsa = proc(node: Node; q: string): seq[Element] = + result = @[] let selectors = parseSelectors(q, node.document.factory) for element in node.elements: if element.selectorsMatch(selectors): result.add(element) -doqsa = (proc(node: Node, q: string): seq[Element] = querySelectorAll(node, q)) -proc querySelector(node: Node; q: string): Element = +doqs = proc(node: Node; q: string): Element = let selectors = parseSelectors(q, node.document.factory) for element in node.elements: if element.selectorsMatch(selectors): return element return nil -doqs = (proc(node: Node, q: string): Element = querySelector(node, q)) |