diff options
-rw-r--r-- | src/html/dom.nim | 5 |
1 files changed, 3 insertions, 2 deletions
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.} = |