From 87699322500be8b407452f1ac067b17fc6f8813d Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 22 Jul 2024 08:03:50 -0400 Subject: [PATCH 1/4] fix: add check for whether view transitions are supported --- packages/query/src/internal.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/query/src/internal.ts b/packages/query/src/internal.ts index 1110827..84d8f78 100644 --- a/packages/query/src/internal.ts +++ b/packages/query/src/internal.ts @@ -1,5 +1,8 @@ import type { scope as scopeFn } from "simple:scope"; -import { transitionEnabledOnThisPage } from "astro/virtual-modules/transitions-router.js"; +import { + transitionEnabledOnThisPage, + supportsViewTransitions, +} from "astro/virtual-modules/transitions-router.js"; export function create$(scope: typeof scopeFn) { const anyMatchSelector = `[data-target$=${JSON.stringify(scope())}`; @@ -25,7 +28,7 @@ export function create$(scope: typeof scopeFn) { return [...document.querySelectorAll(selector)]; }, ready(callback: () => MaybePromise void)>) { - if (transitionEnabledOnThisPage()) { + if (supportsViewTransitions && transitionEnabledOnThisPage()) { let cleanup: (() => void) | undefined; document.addEventListener("astro:page-load", async () => { From 94bef6ff658ffc98898d47d22881f1902f6a9a82 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 22 Jul 2024 08:19:20 -0400 Subject: [PATCH 2/4] fix: check for fallback property --- packages/query/src/internal.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/query/src/internal.ts b/packages/query/src/internal.ts index 84d8f78..532eefa 100644 --- a/packages/query/src/internal.ts +++ b/packages/query/src/internal.ts @@ -28,7 +28,10 @@ export function create$(scope: typeof scopeFn) { return [...document.querySelectorAll(selector)]; }, ready(callback: () => MaybePromise void)>) { - if (supportsViewTransitions && transitionEnabledOnThisPage()) { + const fallback = document + .querySelector('meta[name="astro-view-transitions-fallback"]') + ?.getAttribute("content"); + if (transitionEnabledOnThisPage() && fallback !== "none") { let cleanup: (() => void) | undefined; document.addEventListener("astro:page-load", async () => { From e50045ff2ddba48c96cd517a4481fbfe5818b5de Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 22 Jul 2024 08:20:58 -0400 Subject: [PATCH 3/4] chore: remove unused import --- packages/query/src/internal.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/query/src/internal.ts b/packages/query/src/internal.ts index 532eefa..e66f923 100644 --- a/packages/query/src/internal.ts +++ b/packages/query/src/internal.ts @@ -1,8 +1,5 @@ import type { scope as scopeFn } from "simple:scope"; -import { - transitionEnabledOnThisPage, - supportsViewTransitions, -} from "astro/virtual-modules/transitions-router.js"; +import { transitionEnabledOnThisPage } from "astro/virtual-modules/transitions-router.js"; export function create$(scope: typeof scopeFn) { const anyMatchSelector = `[data-target$=${JSON.stringify(scope())}`; From 56a4000810aed4ddb07f5d8fccd3b7e1c7c8bbd4 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 22 Jul 2024 08:22:12 -0400 Subject: [PATCH 4/4] chore: changeset --- .changeset/metal-sloths-occur.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/metal-sloths-occur.md diff --git a/.changeset/metal-sloths-occur.md b/.changeset/metal-sloths-occur.md new file mode 100644 index 0000000..be5ee94 --- /dev/null +++ b/.changeset/metal-sloths-occur.md @@ -0,0 +1,5 @@ +--- +"simple-stack-query": patch +--- + +fixes issue where `$.ready` does not fire in Safari or Firefox when using Astro view transitions with `fallback="none"`