From 51d83224320b8bd4e81332802bb62158ae6deec5 Mon Sep 17 00:00:00 2001 From: bptato Date: Tue, 13 Sep 2022 20:44:55 +0200 Subject: More JS bindings --- src/css/match.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/css/match.nim') diff --git a/src/css/match.nim b/src/css/match.nim index a50f8396..7d502df1 100644 --- a/src/css/match.nim +++ b/src/css/match.nim @@ -203,15 +203,17 @@ func selectorsMatch*[T: Element|StyledNode](elem: T, selectors: ComplexSelector, return false return true -proc querySelectorAll*(document: Document, q: string): seq[Element] = +proc querySelectorAll(node: Node, q: string): seq[Element] = let selectors = parseSelectors(newStringStream(q)) - for element in document.elements: + 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*(document: Document, q: string): Element = +proc querySelector(node: Node, q: string): Element = let selectors = parseSelectors(newStringStream(q)) - for element in document.elements: + for element in node.elements: if element.selectorsMatch(selectors): return element return nil +doqs = (proc(node: Node, q: string): Element = querySelector(node, q)) -- cgit 1.4.1-2-gfad0