about summary refs log tree commit diff stats
path: root/src/html/chadombuilder.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-09 23:29:38 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-09 23:30:52 +0200
commitc2da7d485cd6b14c6fe59f8c6fe7e16cdbaa8bfd (patch)
treec70debeb6e6a8a7909a06fa6ac802f89a6ff6f69 /src/html/chadombuilder.nim
parentabb3837525a92082b90245db982767f8cf3e3fb6 (diff)
downloadchawan-c2da7d485cd6b14c6fe59f8c6fe7e16cdbaa8bfd.tar.gz
htmlparser: remove more references to dom
Diffstat (limited to 'src/html/chadombuilder.nim')
-rw-r--r--src/html/chadombuilder.nim9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/html/chadombuilder.nim b/src/html/chadombuilder.nim
index 5c7b1770..acddb287 100644
--- a/src/html/chadombuilder.nim
+++ b/src/html/chadombuilder.nim
@@ -50,6 +50,9 @@ proc getTemplateContent(builder: DOMBuilder[Node], handle: Node): Node =
 proc getTagType(builder: DOMBuilder[Node], handle: Node): TagType =
   return Element(handle).tagType
 
+proc getParentNode(builder: DOMBuilder[Node], handle: Node): Node =
+  return handle.parentNode
+
 proc getLocalName(builder: DOMBuilder[Node], handle: Node): string =
   return Element(handle).localName
 
@@ -100,9 +103,8 @@ proc insertText(builder: DOMBuilder[Node], parent: Node, text: string,
     let text = builder.getDocument().createTextNode(text)
     discard parent.insertBefore(text, before)
 
-proc reparent(builder: DOMBuilder[Node], child, newParent: Node) =
+proc remove(builder: DOMBuilder[Node], child: Node) =
   child.remove(true)
-  newParent.append(child)
 
 proc addAttrsIfMissing(builder: DOMBuilder[Node], element: Node,
     attrs: Table[string, string]) =
@@ -155,6 +157,7 @@ proc newChaDOMBuilder(url: URL, window: Window): ChaDOMBuilder =
     elementPopped: elementPopped,
     getTemplateContent: getTemplateContent,
     getTagType: getTagType,
+    getParentNode: getParentNode,
     getLocalName: getLocalName,
     getNamespace: getNamespace,
     createElement: createElement,
@@ -162,7 +165,7 @@ proc newChaDOMBuilder(url: URL, window: Window): ChaDOMBuilder =
     createDocumentType: createDocumentType,
     insertBefore: insertBefore,
     insertText: insertText,
-    reparent: reparent,
+    remove: remove,
     addAttrsIfMissing: addAttrsIfMissing,
     setScriptAlreadyStarted: setScriptAlreadyStarted,
     associateWithForm: associateWithForm,