aboutsummaryrefslogtreecommitdiffstats
path: root/src/html
diff options
context:
space:
mode:
Diffstat (limited to 'src/html')
-rw-r--r--src/html/dom.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 2409388c..b1750d83 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -551,6 +551,7 @@ proc newHTMLElement*(document: Document; tagType: TagType): HTMLElement
proc parseColor(element: Element; s: string): ARGBColor
proc reflectAttr(element: Element; name: CAtom; value: Option[string])
proc remove*(node: Node)
+proc replace*(parent, child, node: Node): Err[DOMException]
proc replaceAll(parent: Node; s: sink string)
proc attrl(element: Element; name: StaticAtom; value: int32)
proc attrul(element: Element; name: StaticAtom; value: uint32)
@@ -3243,6 +3244,25 @@ func jsOptions(this: HTMLSelectElement): HTMLOptionsCollection
)
return this.cachedOptions
+proc setter(ctx: JSContext; this: HTMLOptionsCollection; u: uint32;
+ value: Option[HTMLOptionElement]): DOMResult[void] {.jssetprop.} =
+ let element = this.item(u)
+ if value.isNone:
+ if element != nil:
+ element.remove()
+ return ok()
+ let value = value.get
+ let parent = this.root
+ if element != nil:
+ ?parent.replace(element, value)
+ else:
+ let L = uint32(this.getLength())
+ let document = parent.document
+ for i in L ..< u:
+ parent.append(document.newHTMLElement(TAG_OPTION))
+ parent.append(value)
+ return ok()
+
proc length(this: HTMLSelectElement): int {.jsfget.} =
return this.jsOptions.getLength()