aboutsummaryrefslogtreecommitdiffstats
path: root/src/html
diff options
context:
space:
mode:
Diffstat (limited to 'src/html')
-rw-r--r--src/html/dom.nim5
-rw-r--r--src/html/env.nim2
-rw-r--r--src/html/xmlhttprequest.nim2
3 files changed, 6 insertions, 3 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index b70c061f..582d7907 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -2851,10 +2851,13 @@ func findAutoFocus*(document: Document): Element =
return child
return nil
+proc fireEvent*(window: Window; event: Event; target: EventTarget) =
+ discard window.jsctx.dispatch(target, event)
+
proc fireEvent*(window: Window; name: StaticAtom; target: EventTarget) =
let event = newEvent(window.toAtom(name), target)
event.isTrusted = true
- discard window.jsctx.dispatch(target, event)
+ window.fireEvent(event, target)
proc parseColor(element: Element; s: string): ARGBColor =
let cval = parseComponentValue(s)
diff --git a/src/html/env.nim b/src/html/env.nim
index d140bd44..a771a33f 100644
--- a/src/html/env.nim
+++ b/src/html/env.nim
@@ -327,7 +327,7 @@ proc postMessage(ctx: JSContext; window: Window; value: JSValue): Err[void]
cstring"<postMessage>")
let event = ctx.newMessageEvent(ctx.toAtom(satMessage),
MessageEventInit(data: data))
- discard ctx.dispatch(window, event)
+ window.fireEvent(event, window)
ok()
proc setOnLoad(ctx: JSContext; window: Window; val: JSValue)
diff --git a/src/html/xmlhttprequest.nim b/src/html/xmlhttprequest.nim
index 5f85aee6..af3df80b 100644
--- a/src/html/xmlhttprequest.nim
+++ b/src/html/xmlhttprequest.nim
@@ -194,7 +194,7 @@ proc fireProgressEvent(window: Window; target: EventTarget; name: StaticAtom;
total: length,
lengthComputable: length != 0
))
- discard window.jsctx.dispatch(target, event)
+ window.fireEvent(event, target)
proc errorSteps(window: Window; this: XMLHttpRequest; name: StaticAtom) =
this.readyState = xhrsDone