mirror of
https://github.com/withastro/astro.git
synced 2025-02-10 22:38:53 -05:00
[ci] format
This commit is contained in:
parent
fda3a0213b
commit
b09379428d
3 changed files with 7 additions and 13 deletions
|
@ -25,12 +25,9 @@ const { fallback = 'animate', handleForms } = Astro.props;
|
||||||
</style>
|
</style>
|
||||||
<meta name="astro-view-transitions-enabled" content="true" />
|
<meta name="astro-view-transitions-enabled" content="true" />
|
||||||
<meta name="astro-view-transitions-fallback" content={fallback} />
|
<meta name="astro-view-transitions-fallback" content={fallback} />
|
||||||
{ handleForms ?
|
{handleForms ? <meta name="astro-view-transitions-forms" content="true" /> : ''}
|
||||||
<meta name="astro-view-transitions-forms" content="true" /> :
|
|
||||||
''
|
|
||||||
}
|
|
||||||
<script>
|
<script>
|
||||||
import type { Options } from 'astro:transitions/client';
|
import type { Options } from 'astro:transitions/client';
|
||||||
import { supportsViewTransitions, navigate } from 'astro:transitions/client';
|
import { supportsViewTransitions, navigate } from 'astro:transitions/client';
|
||||||
// NOTE: import from `astro/prefetch` as `astro:prefetch` requires the `prefetch` config to be enabled
|
// NOTE: import from `astro/prefetch` as `astro:prefetch` requires the `prefetch` config to be enabled
|
||||||
import { init } from 'astro/prefetch';
|
import { init } from 'astro/prefetch';
|
||||||
|
@ -83,13 +80,10 @@ import type { Options } from 'astro:transitions/client';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if(document.querySelector('[name="astro-view-transitions-forms"]')) {
|
if (document.querySelector('[name="astro-view-transitions-forms"]')) {
|
||||||
document.addEventListener('submit', (ev) => {
|
document.addEventListener('submit', (ev) => {
|
||||||
let el = ev.target as HTMLElement;
|
let el = ev.target as HTMLElement;
|
||||||
if (
|
if (el.tagName !== 'FORM' || isReloadEl(el)) {
|
||||||
el.tagName !== 'FORM' ||
|
|
||||||
isReloadEl(el)
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +91,7 @@ import type { Options } from 'astro:transitions/client';
|
||||||
const formData = new FormData(form);
|
const formData = new FormData(form);
|
||||||
let action = form.action;
|
let action = form.action;
|
||||||
const options: Options = {};
|
const options: Options = {};
|
||||||
if(form.method === 'get') {
|
if (form.method === 'get') {
|
||||||
const params = new URLSearchParams(formData as any);
|
const params = new URLSearchParams(formData as any);
|
||||||
const url = new URL(action);
|
const url = new URL(action);
|
||||||
url.search = params.toString();
|
url.search = params.toString();
|
||||||
|
|
|
@ -383,7 +383,7 @@ async function transition(
|
||||||
let finished: Promise<void>;
|
let finished: Promise<void>;
|
||||||
const href = toLocation.href;
|
const href = toLocation.href;
|
||||||
const init: RequestInit = {};
|
const init: RequestInit = {};
|
||||||
if(options.formData) {
|
if (options.formData) {
|
||||||
init.method = 'POST';
|
init.method = 'POST';
|
||||||
init.body = options.formData;
|
init.body = options.formData;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue