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

* fix: ensure transition errors are not swallowed

* feedback
pull/11035/head
Dominic Gannaway 8 months 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(() => {
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 {
// Timer
if (t1 === 0) {

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

Loading…
Cancel
Save