about summary refs log tree commit diff stats
path: root/src/html/htmlparser.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-19 20:16:39 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-19 20:17:06 +0200
commit82fb1f70ab275884c42dd769b2af8f9df5389e88 (patch)
treeb7a83ca2e2d22e926959f2525169f2a2e4530e38 /src/html/htmlparser.nim
parent070cfca46f60c3a00fe6dd66457f454a1a217897 (diff)
downloadchawan-82fb1f70ab275884c42dd769b2af8f9df5389e88.tar.gz
Get rid of the .jserr pragma
Diffstat (limited to 'src/html/htmlparser.nim')
-rw-r--r--src/html/htmlparser.nim12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/html/htmlparser.nim b/src/html/htmlparser.nim
index f6af8709..c3df8e3d 100644
--- a/src/html/htmlparser.nim
+++ b/src/html/htmlparser.nim
@@ -14,6 +14,7 @@ import encoding/decoderstream
 import html/dom
 import html/tags
 import html/htmltokenizer
+import js/exception
 import js/javascript
 import types/url
 import utils/twtstr
@@ -239,7 +240,7 @@ proc insert(location: AdjustedInsertionLocation, node: Node) =
 proc insertForeignElement(parser: var HTML5Parser, token: Token, namespace: Namespace): Element =
   let location = parser.appropriatePlaceForInsert()
   let element = parser.createElement(token, namespace, location.inside)
-  if location.inside.preInsertionValidity(element, location.before):
+  if location.inside.preInsertionValidity(element, location.before).isOk:
     #TODO custom elements
     location.insert(element)
   parser.pushElement(element)
@@ -2239,15 +2240,16 @@ proc parseHTML*(inputStream: Stream, charsets: seq[Charset] = @[],
 proc newDOMParser*(): DOMParser {.jsctor.} =
   new(result)
 
-proc parseFromString(parser: DOMParser, str: string, t: string): Document {.jserr, jsfunc.} =
+proc parseFromString(parser: DOMParser, str: string, t: string):
+    Result[Document, JSError] {.jsfunc.} =
   case t
   of "text/html":
     let res = parseHTML(newStringStream(str))
-    return res
+    return ok(res)
   of "text/xml", "application/xml", "application/xhtml+xml", "image/svg+xml":
-    JS_ERR JS_InternalError, "XML parsing is not supported yet"
+    return err(newInternalError("XML parsing is not supported yet"))
   else:
-    JS_ERR JS_TypeError, "Invalid mime type"
+    return err(newTypeError("Invalid mime type"))
 
 proc addHTMLModule*(ctx: JSContext) =
   ctx.registerType(DOMParser)