diff options
author | bptato <nincsnevem662@gmail.com> | 2023-08-28 22:33:31 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-08-28 22:38:00 +0200 |
commit | 1422f3393301cd6105b3939be194c7c119fcf967 (patch) | |
tree | 32969f2af8fe5293c13215a84229915a7970e828 /src/html | |
parent | ba2a62f6d3a2879c9506ea3fb5aa5552fc4674d9 (diff) | |
download | chawan-1422f3393301cd6105b3939be194c7c119fcf967.tar.gz |
javascript: refactor
Split out parts of the JS module, because it was starting to confuse the compiler a little. (Peakmem is back at 750M. Interesting.)
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/chadombuilder.nim | 3 | ||||
-rw-r--r-- | src/html/dom.nim | 7 | ||||
-rw-r--r-- | src/html/env.nim | 3 | ||||
-rw-r--r-- | src/html/event.nim | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/src/html/chadombuilder.nim b/src/html/chadombuilder.nim index da10af20..ad8f7f36 100644 --- a/src/html/chadombuilder.nim +++ b/src/html/chadombuilder.nim @@ -3,6 +3,7 @@ import options import streams import html/dom +import js/error import js/javascript import types/url @@ -204,7 +205,7 @@ proc newDOMParser(): DOMParser {.jsctor.} = new(result) proc parseFromString(ctx: JSContext, parser: DOMParser, str, t: string): - Result[Document, JSError] {.jsfunc.} = + JSResult[Document] {.jsfunc.} = case t of "text/html": let global = JS_GetGlobalObject(ctx) diff --git a/src/html/dom.nim b/src/html/dom.nim index 57b62ec6..6d4b285e 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -18,9 +18,12 @@ import img/png import io/loader import io/request import io/window -import js/exception +import js/domexception +import js/error import js/javascript +import js/opaque import js/timeout +import js/tojs import types/blob import types/color import types/matrix @@ -1101,7 +1104,7 @@ const SupportedTokensMap = { }.toTable() func supports(tokenList: DOMTokenList, token: string): - Result[bool, JSError] {.jsfunc.} = + JSResult[bool] {.jsfunc.} = if tokenList.localName in SupportedTokensMap: let lowercase = token.toLowerAscii() return ok(lowercase in SupportedTokensMap[tokenList.localName]) diff --git a/src/html/env.nim b/src/html/env.nim index 82ed163b..0843c1b6 100644 --- a/src/html/env.nim +++ b/src/html/env.nim @@ -10,7 +10,8 @@ import io/promise import io/request import io/response import io/window -import js/exception +import js/domexception +import js/error import js/intl import js/javascript import js/timeout diff --git a/src/html/event.nim b/src/html/event.nim index 433e9597..dd946820 100644 --- a/src/html/event.nim +++ b/src/html/event.nim @@ -2,7 +2,9 @@ import math import times import bindings/quickjs +import js/error import js/javascript +import js/tojs import utils/opt type |