Add StorageEvent and correct Storage object (#16865)

There is no `LocalStorage` type, it's `Storage`
This commit is contained in:
Antonis Geralis 2021-01-29 21:37:31 +02:00 • committed by GitHub
commit 2c70734913
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,7 @@ type
onmouseup*: proc (event: Event) {.closure.} onmouseup*: proc (event: Event) {.closure.}
onreset*: proc (event: Event) {.closure.} onreset*: proc (event: Event) {.closure.}
onselect*: proc (event: Event) {.closure.} onselect*: proc (event: Event) {.closure.}
onstorage*: proc (event: Event) {.closure.}
onsubmit*: proc (event: Event) {.closure.} onsubmit*: proc (event: Event) {.closure.}
onunload*: proc (event: Event) {.closure.} onunload*: proc (event: Event) {.closure.}
onloadstart*: proc (event: Event) {.closure.} onloadstart*: proc (event: Event) {.closure.}
@ -72,6 +73,7 @@ type
Resize = "resize", Resize = "resize",
Scroll = "scroll", Scroll = "scroll",
Select = "select", Select = "select",
Storage = "storage",
Unload = "unload", Unload = "unload",
Wheel = "wheel" Wheel = "wheel"
@ -125,7 +127,7 @@ type
rangeCount*: int rangeCount*: int
`type`*: cstring `type`*: cstring
LocalStorage* {.importc.} = ref object Storage* {.importc.} = ref object
Window* = ref WindowObj Window* = ref WindowObj
WindowObj {.importc.} = object of EventTargetObj WindowObj {.importc.} = object of EventTargetObj
@ -153,7 +155,8 @@ type
screen*: Screen screen*: Screen
performance*: Performance performance*: Performance
onpopstate*: proc (event: Event) onpopstate*: proc (event: Event)
localStorage*: LocalStorage localStorage*: Storage
sessionStorage*: Storage
parent*: Window parent*: Window
Frame* = ref FrameObj Frame* = ref FrameObj
@ -1210,6 +1213,13 @@ type
## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent>`_ ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent>`_
clipboardData*: DataTransfer 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 TouchList* {.importc.} = ref object of RootObj
length*: int length*: int
@ -1654,12 +1664,12 @@ proc getRangeAt*(s: Selection, index: int): Range
converter toString*(s: Selection): cstring converter toString*(s: Selection): cstring
proc `$`*(s: Selection): string = $(s.toString()) proc `$`*(s: Selection): string = $(s.toString())
# LocalStorage "methods" # Storage "methods"
proc getItem*(ls: LocalStorage, key: cstring): cstring proc getItem*(s: Storage, key: cstring): cstring
proc setItem*(ls: LocalStorage, key, value: cstring) proc setItem*(s: Storage, key, value: cstring)
proc hasItem*(ls: LocalStorage, key: cstring): bool proc hasItem*(s: Storage, key: cstring): bool
proc clear*(ls: LocalStorage) proc clear*(s: Storage)
proc removeItem*(ls: LocalStorage, key: cstring) proc removeItem*(s: Storage, key: cstring)
{.pop.} {.pop.}