From ea9df035a294bf1cfa715c140d0d22aa018e262e Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 19 Dec 2022 21:03:15 +0100 Subject: More DOM work --- src/html/htmlparser.nim | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/html/htmlparser.nim') 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) ) ("", "", "", "", "", "", "<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 -- cgit 1.4.1-2-gfad0