Skip to content

Commit 61b82cc

Browse files
kfuledead-claudia
authored andcommitted
feat: Make redraws when Promises returned by event handlers are completed
1 parent 67d4dfb commit 61b82cc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

render/render.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,15 @@ module.exports = function() {
810810
var result
811811
if (typeof handler === "function") result = handler.call(ev.currentTarget, ev)
812812
else if (typeof handler.handleEvent === "function") handler.handleEvent(ev)
813-
if (this._ && ev.redraw !== false) (0, this._)()
813+
var eventRedraw = this._
814+
if (eventRedraw && ev.redraw !== false) {
815+
eventRedraw()
816+
if (result != null && typeof result.then === "function") {
817+
Promise.resolve(result).finally(function () {
818+
if (ev.redraw !== false) eventRedraw()
819+
})
820+
}
821+
}
814822
if (result === false) {
815823
ev.preventDefault()
816824
ev.stopPropagation()

0 commit comments

Comments
 (0)