diff options
author | bptato <nincsnevem662@gmail.com> | 2024-01-24 12:54:36 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-01-24 12:54:36 +0100 |
commit | b69d0cd7e7bbde418c4bbb6d50f6c4270d1edf0f (patch) | |
tree | 7f4d5ae137e87c5b401d7b24490b5656a3c899d1 /src/js/tojs.nim | |
parent | fe2d01b8d6d569bf8855979ab0e83ae03b62eb73 (diff) | |
download | chawan-b69d0cd7e7bbde418c4bbb6d50f6c4270d1edf0f.tar.gz |
js: define toStringTag properly
Diffstat (limited to 'src/js/tojs.nim')
-rw-r--r-- | src/js/tojs.nim | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/js/tojs.nim b/src/js/tojs.nim index 2936ba28..c79d1bf2 100644 --- a/src/js/tojs.nim +++ b/src/js/tojs.nim @@ -105,6 +105,15 @@ makeToJSP(Result) makeToJSP(JSValue) makeToJSP(JSDict) +proc defineProperty(ctx: JSContext, this: JSValue, name: JSAtom, + prop: JSValue, flags = cint(0)) = + if JS_DefinePropertyValue(ctx, this, name, prop, flags) <= 0: + raise newException(Defect, "Failed to define property string") + +proc definePropertyC*(ctx: JSContext, this: JSValue, name: JSAtom, + prop: JSValue) = + ctx.defineProperty(this, name, prop, JS_PROP_CONFIGURABLE) + proc defineProperty(ctx: JSContext, this: JSValue, name: string, prop: JSValue, flags = cint(0)) = if JS_DefinePropertyValueStr(ctx, this, cstring(name), prop, flags) <= 0: |