Skip to content

Commit 12a056c

Browse files
kfuledead-claudia
authored andcommitted
do not asynchronous redraw when returned Promise is rejected
1 parent ea2be5d commit 12a056c

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

render/render.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ module.exports = function() {
814814
if (eventRedraw && ev.redraw !== false) {
815815
eventRedraw()
816816
if (result != null && typeof result.then === "function") {
817-
Promise.resolve(result).finally(function () {
817+
Promise.resolve(result).then(function () {
818818
if (ev.redraw !== false) eventRedraw()
819819
})
820820
}

render/tests/test-event.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ o.spec("event", function() {
525525
})
526526
})
527527
})
528-
o.spec("reject", function() {
528+
o.spec("do not asynchronous redraw when returned Promise is rejected", function() {
529529
var error
530530
o.beforeEach(function(){
531531
error = console.error
@@ -544,14 +544,14 @@ o.spec("event", function() {
544544
render(root, div)
545545
div.dom.dispatchEvent(e)
546546

547+
// sync redraw
547548
o(redraw.callCount).equals(1)
548549
o(redraw.this).equals(undefined)
549550
o(redraw.args.length).equals(0)
550551

551552
callAsync(function() {
552-
o(redraw.callCount).equals(2)
553-
o(redraw.this).equals(undefined)
554-
o(redraw.args.length).equals(0)
553+
// do not async redraw
554+
o(redraw.callCount).equals(1)
555555

556556
// called console.error
557557
o(consoleSpy.callCount).equals(1)
@@ -572,6 +572,7 @@ o.spec("event", function() {
572572
render(root, div)
573573
div.dom.dispatchEvent(e)
574574

575+
// sync redraw
575576
o(redraw.callCount).equals(1)
576577
o(redraw.this).equals(undefined)
577578
o(redraw.args.length).equals(0)
@@ -583,9 +584,8 @@ o.spec("event", function() {
583584
// reject
584585
rejectCB("error")
585586
callAsync(function() {
586-
o(redraw.callCount).equals(2)
587-
o(redraw.this).equals(undefined)
588-
o(redraw.args.length).equals(0)
587+
// do not async redraw
588+
o(redraw.callCount).equals(1)
589589

590590
// called console.error
591591
o(consoleSpy.callCount).equals(1)
@@ -607,6 +607,7 @@ o.spec("event", function() {
607607
render(root, div)
608608
div.dom.dispatchEvent(e)
609609

610+
// sync redraw
610611
o(redraw.callCount).equals(1)
611612
o(redraw.this).equals(undefined)
612613
o(redraw.args.length).equals(0)
@@ -618,9 +619,8 @@ o.spec("event", function() {
618619
// reject
619620
rejectCB("error")
620621
callAsync(function() {
621-
o(redraw.callCount).equals(2)
622-
o(redraw.this).equals(undefined)
623-
o(redraw.args.length).equals(0)
622+
// do not async redraw
623+
o(redraw.callCount).equals(1)
624624

625625
// called console.error
626626
o(consoleSpy.callCount).equals(1)
@@ -643,6 +643,7 @@ o.spec("event", function() {
643643
render(root, div)
644644
div.dom.dispatchEvent(e)
645645

646+
// sync redraw
646647
o(redraw.callCount).equals(1)
647648
o(redraw.this).equals(undefined)
648649
o(redraw.args.length).equals(0)
@@ -654,9 +655,8 @@ o.spec("event", function() {
654655
// resolve (and throw Error)
655656
thenCB()
656657
callAsync(function() {
657-
o(redraw.callCount).equals(2)
658-
o(redraw.this).equals(undefined)
659-
o(redraw.args.length).equals(0)
658+
// do not async redraw
659+
o(redraw.callCount).equals(1)
660660

661661
// called console.error
662662
o(consoleSpy.callCount).equals(1)
@@ -679,6 +679,7 @@ o.spec("event", function() {
679679
render(root, div)
680680
div.dom.dispatchEvent(e)
681681

682+
// sync redraw
682683
o(redraw.callCount).equals(1)
683684
o(redraw.this).equals(undefined)
684685
o(redraw.args.length).equals(0)
@@ -690,9 +691,8 @@ o.spec("event", function() {
690691
// resolve (and throw Error)
691692
thenCB()
692693
callAsync(function() {
693-
o(redraw.callCount).equals(2)
694-
o(redraw.this).equals(undefined)
695-
o(redraw.args.length).equals(0)
694+
// do not async redraw
695+
o(redraw.callCount).equals(1)
696696

697697
// called console.error
698698
o(consoleSpy.callCount).equals(1)
@@ -714,6 +714,7 @@ o.spec("event", function() {
714714
render(root, div)
715715
div.dom.dispatchEvent(e)
716716

717+
// sync redraw
717718
o(redraw.callCount).equals(1)
718719
o(redraw.this).equals(undefined)
719720
o(redraw.args.length).equals(0)
@@ -725,9 +726,8 @@ o.spec("event", function() {
725726
// reject
726727
rejectCB("error")
727728
callAsync(function() {
728-
o(redraw.callCount).equals(2)
729-
o(redraw.this).equals(undefined)
730-
o(redraw.args.length).equals(0)
729+
// do not async redraw
730+
o(redraw.callCount).equals(1)
731731

732732
// called console.error
733733
o(consoleSpy.callCount).equals(1)
@@ -749,6 +749,7 @@ o.spec("event", function() {
749749
render(root, div)
750750
div.dom.dispatchEvent(e)
751751

752+
// sync redraw
752753
o(redraw.callCount).equals(1)
753754
o(redraw.this).equals(undefined)
754755
o(redraw.args.length).equals(0)
@@ -760,9 +761,8 @@ o.spec("event", function() {
760761
// resolve
761762
rejectCB("error")
762763
callAsync(function() {
763-
o(redraw.callCount).equals(2)
764-
o(redraw.this).equals(undefined)
765-
o(redraw.args.length).equals(0)
764+
// do not async redraw
765+
o(redraw.callCount).equals(1)
766766

767767
// called console.error
768768
o(consoleSpy.callCount).equals(1)

0 commit comments

Comments
 (0)