about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/html/catom.nim6
-rw-r--r--src/html/dom.nim22
2 files changed, 28 insertions, 0 deletions
diff --git a/src/html/catom.nim b/src/html/catom.nim
index 046b37dc..4a0b4f65 100644
--- a/src/html/catom.nim
+++ b/src/html/catom.nim
@@ -43,6 +43,7 @@ macro makeStaticAtom =
       satEnctype = "enctype"
       satError = "error"
       satEvent = "event"
+      satEvents = "events"
       satFor = "for"
       satForm = "form"
       satFormaction = "formaction"
@@ -92,6 +93,7 @@ macro makeStaticAtom =
       satSrcset = "srcset"
       satStyle = "style"
       satStylesheet = "stylesheet"
+      satSvgevents = "svgevents"
       satTarget = "target"
       satText = "text"
       satTimeout = "timeout"
@@ -99,6 +101,7 @@ macro makeStaticAtom =
       satTouchmove = "touchmove"
       satTouchstart = "touchstart"
       satType = "type"
+      satUEvent = "Event"
       satUsemap = "usemap"
       satUsername = "username"
       satValign = "valign"
@@ -216,6 +219,9 @@ var getFactoryImpl*: proc(ctx: JSContext): CAtomFactory {.nimcall, noSideEffect,
 proc toAtom*(ctx: JSContext; atom: StaticAtom): CAtom =
   return ctx.getFactoryImpl().toAtom(atom)
 
+proc toAtom*(ctx: JSContext; s: string): CAtom =
+  return ctx.getFactoryImpl().toAtom(s)
+
 proc toStaticAtom*(ctx: JSContext; atom: CAtom): StaticAtom =
   return ctx.getFactoryImpl().toStaticAtom(atom)
 
diff --git a/src/html/dom.nim b/src/html/dom.nim
index d173c40d..2f285899 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -1602,6 +1602,7 @@ func item(this: HTMLCollection; u: uint32): Element {.jsfunc.} =
   return nil
 
 func namedItem(this: HTMLCollection; atom: CAtom): Element {.jsfunc.} =
+  this.refreshCollection()
   for it in this.snapshot:
     let it = Element(it)
     if it.id == atom or it.namespace == Namespace.HTML and it.name == atom:
@@ -2732,6 +2733,10 @@ func elements(form: HTMLFormElement): HTMLFormControlsCollection {.jsfget.} =
     )
   return form.cachedElements
 
+proc getter(ctx: JSContext; this: HTMLFormElement; atom: JSAtom): JSValue
+    {.jsgetprop.} =
+  return ctx.getter(this.elements, atom)
+
 # <input>
 func jsForm(this: HTMLInputElement): HTMLFormElement {.jsfget: "form".} =
   return this.form
@@ -2756,6 +2761,14 @@ func isOptionOf(node: Node; select: HTMLSelectElement): bool =
       parent of HTMLOptGroupElement and parent.parentNode == select
   return false
 
+proc names(ctx: JSContext; this: HTMLOptionsCollection): JSPropertyEnumList
+    {.jspropnames.} =
+  return ctx.names(HTMLCollection(this))
+
+proc getter(ctx: JSContext; this: HTMLOptionsCollection; atom: JSAtom): Element
+    {.jsgetprop.} =
+  return ctx.getter(HTMLCollection(this), atom)
+
 func jsOptions(this: HTMLSelectElement): HTMLOptionsCollection
     {.jsfget: "options".} =
   if this.cachedOptions == nil:
@@ -4378,6 +4391,12 @@ proc createProcessingInstruction(document: Document; target, data: string):
       "InvalidCharacterError")
   return ok(newProcessingInstruction(document, target, data))
 
+proc createEvent(ctx: JSContext; document: Document; t: StaticAtom):
+    DOMResult[Event] {.jsfunc.} =
+  if t notin {satUEvent, satEvent, satEvents, satSvgevents}:
+    return errDOMException("Event not supported", "NotSupportedError")
+  return ok(newEvent(ctx.toAtom(""), nil))
+
 proc clone(node: Node; document = none(Document), deep = false): Node =
   let document = document.get(node.document)
   let copy = if node of Element:
@@ -4385,6 +4404,9 @@ proc clone(node: Node; document = none(Document), deep = false): Node =
     let element = Element(node)
     let x = document.newHTMLElement(element.localName, element.namespace,
       element.namespacePrefix)
+    x.id = element.id
+    x.name = element.name
+    x.classList = DOMTokenList(element: x, localName: element.localName)
     x.attrs = element.attrs
     #TODO namespaced attrs?
     # Cloning steps