about summary refs log tree commit diff stats
path: root/src/html/catom.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-04 18:47:55 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-17 19:40:44 +0200
commitf868027fed934904718962b69c88cc7e2008e2c3 (patch)
treec2859362c7f8a1c26cb7103d0f4ba96f3d9f8d49 /src/html/catom.nim
parentdd5f480ebecec6758991c226af208c79e2fe9cbc (diff)
downloadchawan-f868027fed934904718962b69c88cc7e2008e2c3.tar.gz
dom: add forms, elements getter + misc fixes
* add document.forms
* add form.elements
* remove redundant jshasprop functions
* use mpairs for attribute iteration (mpairs use pointers, but pairs
  copies)
* fix remove() crash
* fix remove() collection invalidation for children (if parent is not
  in the collection)
* update monoucha
Diffstat (limited to 'src/html/catom.nim')
-rw-r--r--src/html/catom.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/html/catom.nim b/src/html/catom.nim
index 111abb8d..3590bc63 100644
--- a/src/html/catom.nim
+++ b/src/html/catom.nim
@@ -198,7 +198,8 @@ func toStaticAtom*(factory: CAtomFactory; atom: CAtom): StaticAtom =
     return StaticAtom(i)
   return atUnknown
 
-var getFactory*: proc(ctx: JSContext): CAtomFactory {.nimcall, noSideEffect.}
+var getFactory*: proc(ctx: JSContext): CAtomFactory {.nimcall, noSideEffect,
+  raises: [].}
 
 proc toAtom*(ctx: JSContext; atom: StaticAtom): CAtom =
   return ctx.getFactory().toAtom(atom)
@@ -212,6 +213,12 @@ proc fromJS*(ctx: JSContext; val: JSValue; res: var CAtom): Opt[void] =
   res = ctx.getFactory().toAtom(s)
   return ok()
 
+proc fromJS*(ctx: JSContext; val: JSAtom; res: var CAtom): Opt[void] =
+  var s: string
+  ?ctx.fromJS(val, s)
+  res = ctx.getFactory().toAtom(s)
+  return ok()
+
 proc toJS*(ctx: JSContext; atom: CAtom): JSValue =
   return ctx.toJS(ctx.getFactory().toStr(atom))