diff options
author | bptato <nincsnevem662@gmail.com> | 2023-11-19 18:08:02 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-11-19 18:08:02 +0100 |
commit | 4cd0ce53d14ad2c4ed795d6cb86920eb6a279f8f (patch) | |
tree | 1e08af240af5c3e964235e1c3fce9561a7f51211 | |
parent | 7a218e68dd92fa5b12666a423c07950f63d700b7 (diff) | |
download | chawan-4cd0ce53d14ad2c4ed795d6cb86920eb6a279f8f.tar.gz |
minidom: fix insertText if before is first in parent
-rw-r--r-- | chame/minidom.nim | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/chame/minidom.nim b/chame/minidom.nim index 5e6f0938..717f4b59 100644 --- a/chame/minidom.nim +++ b/chame/minidom.nim @@ -166,7 +166,11 @@ proc insertBefore(builder: DOMBuilder[Node], parent, child, before: Node) = proc insertText(builder: DOMBuilder[Node], parent: Node, text: string, before: Node) = let prevSibling = if before != nil: - parent.childList[parent.childList.find(before) - 1] + let i = parent.childList.find(before) + if i == 0: + nil + else: + parent.childList[i - 1] elif parent.childList.len > 0: parent.childList[^1] else: |