diff options
author | bptato <nincsnevem662@gmail.com> | 2023-12-01 21:25:09 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-01 21:29:29 +0100 |
commit | b7482b23c98ecd9bf60309fe9c06b5539595d492 (patch) | |
tree | 640aeaf8a3a39a9a6fded2a466592134fd839c97 /src/js | |
parent | 90c74ddcab6713f9bb2dfea53a30951cc2e06f88 (diff) | |
download | chawan-b7482b23c98ecd9bf60309fe9c06b5539595d492.tar.gz |
html: add HTMLElement.dataset (+ some twtstr cleanup)
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/javascript.nim | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim index d3de6508..124eab5d 100644 --- a/src/js/javascript.nim +++ b/src/js/javascript.nim @@ -873,7 +873,7 @@ proc setupGenerator(fun: NimNode, t: BoundFunctionType, proc makeJSCallAndRet(gen: var JSFuncGenerator, okstmt, errstmt: NimNode) = let jfcl = gen.jsFunCallList let dl = gen.dielabel - gen.jsCallAndRet = if gen.returnType.issome: + gen.jsCallAndRet = if gen.returnType.isSome: quote do: block `dl`: return ctx.toJS(`jfcl`) @@ -962,11 +962,19 @@ macro jssetprop*(fun: typed) = gen.finishFunCallList() let jfcl = gen.jsFunCallList let dl = gen.dielabel - gen.jsCallAndRet = quote do: - block `dl`: - `jfcl` - return cint(1) - return cint(-1) + gen.jsCallAndRet = if gen.returnType.isSome: + quote do: + block `dl`: + let v = toJS(ctx, `jfcl`) + if not JS_IsException(v): + return cint(1) + return cint(-1) + else: + quote do: + block `dl`: + `jfcl` + return cint(1) + return cint(-1) let jsProc = gen.newJSProc(getJSSetPropParams(), false) gen.registerFunction() return newStmtList(fun, jsProc) |