Skip to content

Commit 89e6a7a

Browse files
authored
Fix the getSelection method. (#13632)
1 parent b8b0e9b commit 89e6a7a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/js/dom.nim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ type
103103
memory*: PerformanceMemory
104104
timing*: PerformanceTiming
105105

106+
Selection* {.importc.} = ref object ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Selection>`_
107+
106108
LocalStorage* {.importc.} = ref object
107109

108110
Window* = ref WindowObj
@@ -1155,7 +1157,7 @@ proc createAttribute*(d: Document, identifier: cstring): Node
11551157
proc getElementsByName*(d: Document, name: cstring): seq[Element]
11561158
proc getElementsByTagName*(d: Document, name: cstring): seq[Element]
11571159
proc getElementsByClassName*(d: Document, name: cstring): seq[Element]
1158-
proc getSelection*(d: Document): cstring
1160+
proc getSelection*(d: Document): Selection
11591161
proc handleEvent*(d: Document, event: Event)
11601162
proc open*(d: Document)
11611163
proc releaseEvents*(d: Document, eventMask: int) {.deprecated.}
@@ -1245,6 +1247,11 @@ proc slice*(e: Blob, startindex: int = 0, endindex: int = e.size, contentType: c
12451247
# Performance "methods"
12461248
proc now*(p: Performance): float
12471249

1250+
# Selection "methods"
1251+
proc removeAllRanges*(s: Selection)
1252+
converter toString*(s: Selection): cstring
1253+
proc `$`*(s: Selection): string = $(s.toString())
1254+
12481255
# LocalStorage "methods"
12491256
proc getItem*(ls: LocalStorage, key: cstring): cstring
12501257
proc setItem*(ls: LocalStorage, key, value: cstring)

0 commit comments

Comments
 (0)