summary refs log tree commit diff stats
path: root/lib/js
diff options
context:
space:
mode:
authortreeform <starplant@gmail.com>2020-04-21 05:57:19 -0700
committerGitHub <noreply@github.com>2020-04-21 14:57:19 +0200
commit89e6a7ab48584e2bcfc4a5c1997c292671d2bb6c (patch)
tree6ce4b3e12e09e4cccbe73dcf6afa49b6b07ae5b4 /lib/js
parentb8b0e9b21d0b6da8c807efc6bbb339cd89c6236f (diff)
downloadNim-89e6a7ab48584e2bcfc4a5c1997c292671d2bb6c.tar.gz
Fix the getSelection method. (#13632)
Diffstat (limited to 'lib/js')
-rw-r--r--lib/js/dom.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/js/dom.nim b/lib/js/dom.nim
index a0df4b7b9..a6fdf3326 100644
--- a/lib/js/dom.nim
+++ b/lib/js/dom.nim
@@ -103,6 +103,8 @@ type
     memory*: PerformanceMemory
     timing*: PerformanceTiming
 
+  Selection* {.importc.} = ref object ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Selection>`_
+
   LocalStorage* {.importc.} = ref object
 
   Window* = ref WindowObj
@@ -1155,7 +1157,7 @@ proc createAttribute*(d: Document, identifier: cstring): Node
 proc getElementsByName*(d: Document, name: cstring): seq[Element]
 proc getElementsByTagName*(d: Document, name: cstring): seq[Element]
 proc getElementsByClassName*(d: Document, name: cstring): seq[Element]
-proc getSelection*(d: Document): cstring
+proc getSelection*(d: Document): Selection
 proc handleEvent*(d: Document, event: Event)
 proc open*(d: Document)
 proc releaseEvents*(d: Document, eventMask: int) {.deprecated.}
@@ -1245,6 +1247,11 @@ proc slice*(e: Blob, startindex: int = 0, endindex: int = e.size, contentType: c
 # Performance "methods"
 proc now*(p: Performance): float
 
+# Selection "methods"
+proc removeAllRanges*(s: Selection)
+converter toString*(s: Selection): cstring
+proc `$`*(s: Selection): string = $(s.toString())
+
 # LocalStorage "methods"
 proc getItem*(ls: LocalStorage, key: cstring): cstring
 proc setItem*(ls: LocalStorage, key, value: cstring)