summaryrefslogtreecommitdiffhomepage
path: root/vitest-setup.ts
diff options
context:
space:
mode:
Diffstat (limited to 'vitest-setup.ts')
-rw-r--r--vitest-setup.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/vitest-setup.ts b/vitest-setup.ts
index a0ace27..94aa5e8 100644
--- a/vitest-setup.ts
+++ b/vitest-setup.ts
@@ -42,3 +42,15 @@ if (typeof globalThis.PointerEvent === "undefined") {
}
globalThis.PointerEvent = PointerEventPolyfill as unknown as typeof PointerEvent;
}
+
+// jsdom has no native modal dialog lifecycle. Fake only this browser edge;
+// real-browser checks cover top-layer rendering and native focus containment.
+if (typeof HTMLDialogElement !== "undefined" && !HTMLDialogElement.prototype.showModal) {
+ HTMLDialogElement.prototype.showModal = function () {
+ this.open = true;
+ this.querySelector<HTMLElement>("button")?.focus();
+ };
+ HTMLDialogElement.prototype.close = function () {
+ this.open = false;
+ };
+}