about summary refs log tree commit diff stats
path: root/src/html/htmlparser.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-19 21:03:15 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-19 21:03:15 +0100
commitea9df035a294bf1cfa715c140d0d22aa018e262e (patch)
tree9f1ec79e96003494666970c16f905c0b0c9608ff /src/html/htmlparser.nim
parentdad0c1c04b6d4f67da407f69cec98221d178c194 (diff)
downloadchawan-ea9df035a294bf1cfa715c140d0d22aa018e262e.tar.gz
More DOM work
Diffstat (limited to 'src/html/htmlparser.nim')
-rw-r--r--src/html/htmlparser.nim15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/html/htmlparser.nim b/src/html/htmlparser.nim
index 999625a8..f306d5f4 100644
--- a/src/html/htmlparser.nim
+++ b/src/html/htmlparser.nim
@@ -205,8 +205,7 @@ func createElement(parser: HTML5Parser, token: Token, namespace: Namespace, inte
   #TODO custom elements
   let document = intendedParent.document
   let localName = token.tagname
-  let element = document.newHTMLElement(localName, namespace, tagType = token.tagtype)
-  element.appendAttributes(token.attrs)
+  let element = document.newHTMLElement(localName, namespace, tagType = token.tagtype, attrs = token.attrs)
   if element.isResettable():
     element.resetElement()
 
@@ -1086,10 +1085,12 @@ proc processInHTMLContent(parser: var HTML5Parser, token: Token, insertionMode =
         let token = parser.activeFormatting[formattingIndex][1]
         let element = parser.createElement(token, Namespace.HTML, furthestBlock)
         var tomove: seq[Node]
-        for j in countdown(furthestBlock.childNodes.high, 0):
-          let child = furthestBlock.childNodes[j]
-          child.remove()
+        j = furthestBlock.childList.high
+        while j >= 0:
+          let child = furthestBlock.childList[j]
+          child.remove(j, true)
           tomove.add(child)
+          dec j
         for child in tomove:
           element.append(child)
         furthestBlock.append(element)
@@ -1139,7 +1140,7 @@ proc processInHTMLContent(parser: var HTML5Parser, token: Token, insertionMode =
         else:
           for k, v in token.attrs:
             if k notin parser.openElements[0].attrs:
-              parser.openElements[0].attrs[k] = v
+              parser.openElements[0].attr(k, v)
       )
       ("<base>", "<basefont>", "<bgsound>", "<link>", "<meta>", "<noframes>", "<script>", "<style>", "<template>", "<title>",
        "</template>") => (block: parser.processInHTMLContent(token, IN_HEAD))
@@ -1151,7 +1152,7 @@ proc processInHTMLContent(parser: var HTML5Parser, token: Token, insertionMode =
           parser.framesetOk = false
           for k, v in token.attrs:
             if k notin parser.openElements[1].attrs:
-              parser.openElements[1].attrs[k] = v
+              parser.openElements[1].attr(k, v)
       )
       "<frameset>" => (block:
         parse_error