about summary refs log tree commit diff stats
path: root/src/html/htmlparser.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/html/htmlparser.nim')
-rw-r--r--src/html/htmlparser.nim18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/html/htmlparser.nim b/src/html/htmlparser.nim
index a9952f11..6fbc4ae7 100644
--- a/src/html/htmlparser.nim
+++ b/src/html/htmlparser.nim
@@ -99,10 +99,7 @@ proc resetInsertionMode(parser: var HTML5Parser) =
       switch_insertion_mode_and_return IN_BODY
 
 func currentNode(parser: HTML5Parser): Element =
-  if parser.openElements.len == 0:
-    assert false
-  else:
-    return parser.openElements[^1]
+  return parser.openElements[^1]
 
 func adjustedCurrentNode(parser: HTML5Parser): Element =
   if parser.fragment: parser.ctx
@@ -222,6 +219,19 @@ func createElement(parser: HTML5Parser, token: Token, namespace: Namespace, inte
     element.parserInserted = true
   return element
 
+proc pushElement(parser: var HTML5Parser, node: Element) =
+  parser.openElements.add(node)
+  parser.tokenizer.hasnonhtml = not parser.adjustedCurrentNode().inHTMLNamespace()
+
+proc popElement(parser: var HTML5Parser): Element =
+  result = parser.openElements.pop()
+  if result.tagType == TAG_TEXTAREA:
+    result.resetElement()
+  if parser.openElements.len == 0:
+    parser.tokenizer.hasnonhtml = false
+  else:
+    parser.tokenizer.hasnonhtml = not parser.adjustedCurrentNode().inHTMLNamespace()
+
 proc insert(location: AdjustedInsertionLocation, node: Node) =
   location.inside.insert(node, location.before)