about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-04-21 19:17:10 +0200
committerbptato <nincsnevem662@gmail.com>2024-04-21 19:17:10 +0200
commit470aeef2d72614cb8f904d8ef19583312410d981 (patch)
tree20cebeb73b89000d4ee43b1d95c98d271ae84483 /src/html
parent31b359224632fd4e3c2aac667483ed249121efaa (diff)
downloadchawan-470aeef2d72614cb8f904d8ef19583312410d981.tar.gz
js: fix some incorrect defineProperty usage
It consumes a value, so we must dup those that we pass.
Diffstat (limited to 'src/html')
-rw-r--r--src/html/dom.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 417237bb..8767ac6e 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -1446,7 +1446,7 @@ proc newLocation*(window: Window): Location =
   if ctx != nil:
     let val = toJS(ctx, location)
     let valueOf = ctx.getOpaque().Object_prototype_valueOf
-    defineProperty(ctx, val, "valueOf", valueOf)
+    defineProperty(ctx, val, "valueOf", JS_DupValue(ctx, valueOf))
     defineProperty(ctx, val, "toPrimitive", JS_UNDEFINED)
     #TODO [[DefaultProperties]]
     JS_FreeValue(ctx, val)
@@ -2855,7 +2855,7 @@ proc reflectEvent(element: Element; target: EventTarget; name: StaticAtom;
       urls, ctx.getExceptionMsg())
   else:
     let jsTarget = ctx.toJS(target)
-    ctx.definePropertyC(jsTarget, $name, fun)
+    ctx.definePropertyC(jsTarget, $name, JS_DupValue(ctx, fun))
     JS_FreeValue(ctx, jsTarget)
     #TODO this is subtly wrong. In fact, we should not pass `fun'
     # directly here, but a wrapper function that calls fun. Currently