aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-01 23:26:17 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-01 23:26:17 +0200
commit2f74b628f3c91860860cc19fc07db5c304e8e6ed (patch)
tree161bd11827648bd89042ccb30b7d6fdae523272d /src
parent2b10a9b7f61d58157f85c93e8e7b18b1e01e4b79 (diff)
downloadchawan-2f74b628f3c91860860cc19fc07db5c304e8e6ed.tar.gz
Use separate flag for adding getset instead of repr
Still a hack, but maybe more reliable?
Diffstat (limited to 'src')
-rw-r--r--src/html/dom.nim4
-rw-r--r--src/js/javascript.nim8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index bf8e0fcc..ee4d5620 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -2990,11 +2990,11 @@ proc registerElements(ctx: JSContext, nodeCID: JSClassID) =
let elementCID = ctx.registerType(Element, parent = nodeCID)
const extra_getset = getElementReflectFunctions()
let htmlElementCID = ctx.registerType(HTMLElement, parent = elementCID,
- extra_getset = extra_getset)
+ has_extra_getset = true, extra_getset = extra_getset)
template register(t: typed, tags: set[TagType]) =
const extra_getset = getReflectFunctions(tags)
ctx.registerType(t, parent = htmlElementCID,
- extra_getset = extra_getset)
+ has_extra_getset = true, extra_getset = extra_getset)
template register(t: typed, tag: TagType) =
register(t, {tag})
register(HTMLInputElement, TAG_INPUT)
diff --git a/src/js/javascript.nim b/src/js/javascript.nim
index b2334be6..3e6eec14 100644
--- a/src/js/javascript.nim
+++ b/src/js/javascript.nim
@@ -1743,6 +1743,7 @@ template jsDestructor*[U](T: typedesc[ref U]) =
macro registerType*(ctx: typed, t: typed, parent: JSClassID = 0,
asglobal = false, nointerface = false, name: static string = "",
+ has_extra_getset: static bool = false,
extra_getset: static openarray[TabGetSet] = [],
namespace: JSValue = JS_NULL, errid = opt(JSErrorEnum)): JSClassID =
result = newStmtList()
@@ -1832,11 +1833,10 @@ macro registerType*(ctx: typed, t: typed, parent: JSClassID = 0,
if k notin getters:
tabList.add(quote do: JS_CGETSET_DEF(`k`, nil, `v`))
- for x in extra_getset:
- #TODO TODO TODO what the hell is this...
- # For some reason, extra_getset gets weird contents when nothing is
+ if has_extra_getset:
+ #HACK: for some reason, extra_getset gets weird contents when nothing is
# passed to it.
- if repr(x) != "" and repr(x) != "[]":
+ for x in extra_getset:
let k = x.name
let g = x.get
let s = x.set