Skip to content

Commit

Permalink
Add StorageEvent and correct Storage object (#16865)
Browse files Browse the repository at this point in the history
There is no `LocalStorage` type, it's `Storage`
  • Loading branch information
planetis-m authored Jan 29, 2021
1 parent 1097cc4 commit 2c70734
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/js/dom.nim
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type
onmouseup*: proc (event: Event) {.closure.}
onreset*: proc (event: Event) {.closure.}
onselect*: proc (event: Event) {.closure.}
onstorage*: proc (event: Event) {.closure.}
onsubmit*: proc (event: Event) {.closure.}
onunload*: proc (event: Event) {.closure.}
onloadstart*: proc (event: Event) {.closure.}
Expand Down Expand Up @@ -72,6 +73,7 @@ type
Resize = "resize",
Scroll = "scroll",
Select = "select",
Storage = "storage",
Unload = "unload",
Wheel = "wheel"

Expand Down Expand Up @@ -125,7 +127,7 @@ type
rangeCount*: int
`type`*: cstring

LocalStorage* {.importc.} = ref object
Storage* {.importc.} = ref object

Window* = ref WindowObj
WindowObj {.importc.} = object of EventTargetObj
Expand Down Expand Up @@ -153,7 +155,8 @@ type
screen*: Screen
performance*: Performance
onpopstate*: proc (event: Event)
localStorage*: LocalStorage
localStorage*: Storage
sessionStorage*: Storage
parent*: Window

Frame* = ref FrameObj
Expand Down Expand Up @@ -1210,6 +1213,13 @@ type
## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent>`_
clipboardData*: DataTransfer

StorageEvent* = ref StorageEventObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent>`_
StorageEventObj {.importc.} = object of Event
key*: cstring
newValue*, oldValue*: cstring
storageArea*: Storage
url*: cstring

TouchList* {.importc.} = ref object of RootObj
length*: int

Expand Down Expand Up @@ -1654,12 +1664,12 @@ proc getRangeAt*(s: Selection, index: int): Range
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)
proc hasItem*(ls: LocalStorage, key: cstring): bool
proc clear*(ls: LocalStorage)
proc removeItem*(ls: LocalStorage, key: cstring)
# Storage "methods"
proc getItem*(s: Storage, key: cstring): cstring
proc setItem*(s: Storage, key, value: cstring)
proc hasItem*(s: Storage, key: cstring): bool
proc clear*(s: Storage)
proc removeItem*(s: Storage, key: cstring)

{.pop.}

Expand Down

0 comments on commit 2c70734

Please sign in to comment.