From f2930dad3e29e71a446bfcf2d04078af02fdedd0 Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 14 Sep 2023 12:09:29 +0200 Subject: dom: fix incorrect iteration in descendants --- src/html/dom.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/html') diff --git a/src/html/dom.nim b/src/html/dom.nim index 7843a424..7e2d967b 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -883,11 +883,12 @@ iterator branch*(node: Node): Node {.inline.} = # Returns the node's descendants iterator descendants*(node: Node): Node {.inline.} = var stack: seq[Node] - stack.add(node) + for i in countdown(node.childList.high, 0): + stack.add(node.childList[i]) while stack.len > 0: let node = stack.pop() + yield node for i in countdown(node.childList.high, 0): - yield node.childList[i] stack.add(node.childList[i]) iterator elements*(node: Node): Element {.inline.} = -- cgit