about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-11-16 18:46:21 +0100
committerbptato <nincsnevem662@gmail.com>2024-11-16 19:01:25 +0100
commitba808062f18adfe227cf2f5b3c283f43827274cd (patch)
tree41cc9b18227eb47bd28dbbe97584a55b2a6aeff2 /src/html
parent6a6a0eaea32fd1e75102a663ed6adceef42cbf7c (diff)
downloadchawan-ba808062f18adfe227cf2f5b3c283f43827274cd.tar.gz
dom: add getElementsByName, fix adopt
Diffstat (limited to 'src/html')
-rw-r--r--src/html/dom.nim11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 703cc0d1..558777c5 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -2242,6 +2242,15 @@ func getElementById(document: Document; id: string): Element {.jsfunc.} =
       return child
   return nil
 
+func getElementsByName(document: Document; name: CAtom): NodeList {.jsfunc.} =
+  return newCollection[NodeList](
+    document,
+    func(node: Node): bool =
+      return node of Element and Element(node).name == name,
+    islive = true,
+    childonly = false
+  )
+
 func getElementsByTagName0(root: Node; tagName: string): HTMLCollection =
   if tagName == "*":
     return newCollection[HTMLCollection](
@@ -3697,7 +3706,7 @@ proc adopt(document: Document; node: Node) =
     remove(node)
   if oldDocument != document:
     #TODO shadow root
-    for desc in node.descendants:
+    for desc in node.descendantsIncl:
       desc.internalDocument = document
       if desc of Element:
         for attr in Element(desc).attributes.attrlist: