Skip to the content

Capsid menu

app/lib/transition-abort.mjs

13 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of transition-abort.mjs
FunctionLinesComplexityCoveredCRAPMutation
isAbandonedTransition12 to 143100%OkCRAP 3No data: no mutants in this code

Imports

It imports no other module of this repo. Imported by app/enhance/header.ts.

Source

// A cross-document view transition (motion-print.css, type `site`) the browser abandons rejects its promises with
// `InvalidStateError: Transition was aborted because of invalid state`: the page was reloaded, went hidden or was
// navigated again while the transition was still running. Nothing in the page caused it and nothing in the page can
// handle it, since the promise belongs to the browser's own navigation. It is the one error the page lets go: every
// other rejection, including any other InvalidStateError, is still reported.

/**
 * Whether a rejection is the browser abandoning a view transition.
 *
 * @param {unknown} reason
 */
export function isAbandonedTransition(reason) {
  return reason instanceof DOMException && reason.name === "InvalidStateError" && reason.message.startsWith("Transition was aborted");
}