fix: ensure transition errors are not swallowed (#11039)

* fix: ensure transition errors are not swallowed

* feedback
pull/11035/head
Dominic Gannaway 1 year ago committed by GitHub
parent b210fe3c9d
commit c50883e496
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: ensure transition errors are not swallowed

@ -301,7 +301,17 @@ function animate(element, options, counterpart, t2, callback) {
.then(() => { .then(() => {
callback?.(); callback?.();
}) })
.catch(noop); .catch((e) => {
// Error for DOMException: The user aborted a request. This results in two things:
// - startTime is `null`
// - currentTime is `null`
// We can't use the existence of an AbortError as this error and error code is shared
// with other Web APIs such as fetch().
if (animation.startTime !== null && animation.currentTime !== null) {
throw e;
}
});
} else { } else {
// Timer // Timer
if (t1 === 0) { if (t1 === 0) {

@ -42,6 +42,7 @@ class Animation {
#cancelled = () => {}; #cancelled = () => {};
currentTime = 0; currentTime = 0;
startTime = 0;
/** /**
* @param {HTMLElement} target * @param {HTMLElement} target
@ -122,7 +123,10 @@ class Animation {
if (this.currentTime > 0 && this.currentTime < this.#duration) { if (this.currentTime > 0 && this.currentTime < this.#duration) {
this.#apply_keyframe(0); this.#apply_keyframe(0);
} }
// @ts-ignore
this.currentTime = null;
// @ts-ignore
this.startTime = null;
this.#cancelled(); this.#cancelled();
raf.animations.delete(this); raf.animations.delete(this);
} }

Loading…
Cancel
Save