diff --git a/.changeset/purple-jokes-pay.md b/.changeset/purple-jokes-pay.md new file mode 100644 index 0000000000..ddb641371b --- /dev/null +++ b/.changeset/purple-jokes-pay.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue where a form field named "attributes" shadows the form.attributes property. diff --git a/packages/astro/e2e/fixtures/view-transitions/src/pages/form-one.astro b/packages/astro/e2e/fixtures/view-transitions/src/pages/form-one.astro index ca5e4cb825..21ac979ff2 100644 --- a/packages/astro/e2e/fixtures/view-transitions/src/pages/form-one.astro +++ b/packages/astro/e2e/fixtures/view-transitions/src/pages/form-one.astro @@ -12,5 +12,6 @@ export const prerender = false; {postShowThrow ? : ''} + diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index 925aab0a6b..5dc327cf46 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -397,8 +397,7 @@ async function transition( // // Note: getNamedItem can return null in real life, even if TypeScript doesn't think so, hence // the ?. - init.body = - form?.attributes.getNamedItem('enctype')?.value === 'application/x-www-form-urlencoded' + init.body = (from !== undefined && Reflect.get(HTMLFormElement.prototype, "attributes", form).getNamedItem('enctype')?.value === 'application/x-www-form-urlencoded') ? new URLSearchParams(preparationEvent.formData as any) : preparationEvent.formData; }