about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-26 20:48:42 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-26 20:48:42 +0100
commit829e358417cdb38ec7cfd77ea763a35e6c2d6132 (patch)
tree3d44052a7be00bd5bccd204266e549cb7f5050a4 /src/html
parent2d5245d9ecc920c81b39e790bc3e396a61381849 (diff)
downloadchawan-829e358417cdb38ec7cfd77ea763a35e6c2d6132.tar.gz
getElementsByClassName on Document and Element
Instead of Node.
Diffstat (limited to 'src/html')
-rw-r--r--src/html/dom.nim12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 8cd075d9..b51471d3 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -773,7 +773,7 @@ func getElementsByTagName(document: Document, tagName: string): HTMLCollection {
 func getElementsByTagName(element: Element, tagName: string): HTMLCollection {.jsfunc.} =
   return element.getElementsByTagName0(tagName)
 
-func getElementsByClassName(node: Node, classNames: string): HTMLCollection {.jsfunc.} =
+func getElementsByClassName0(node: Node, classNames: string): HTMLCollection =
   var classes = classNames.split(AsciiWhitespace)
   let isquirks = node.document.mode == QUIRKS
   if isquirks:
@@ -795,7 +795,13 @@ func getElementsByClassName(node: Node, classNames: string): HTMLCollection {.js
               return false
         return true, true)
 
-func filterDescendants*(element: Element, predicate: (proc(child: Element): bool)): seq[Element] =
+func getElementsByClassName(document: Document, classNames: string): HTMLCollection {.jsfunc.} =
+  return document.getElementsByClassName0(classNames)
+
+func getElementsByClassName(element: Element, classNames: string): HTMLCollection {.jsfunc.} =
+  return element.getElementsByClassName0(classNames)
+
+func filterDescendants(element: Element, predicate: (proc(child: Element): bool)): seq[Element] =
   var stack: seq[Element]
   for child in element.elementList_rev:
     stack.add(child)
@@ -806,7 +812,7 @@ func filterDescendants*(element: Element, predicate: (proc(child: Element): bool
     for child in element.elementList_rev:
       stack.add(child)
 
-func all_descendants*(element: Element): seq[Element] =
+func all_descendants(element: Element): seq[Element] =
   var stack: seq[Element]
   for child in element.elementList_rev:
     stack.add(child)