Skip to content

Commit 37ed70b

Browse files
fix: input name overriding form method and action checks (#8471)
* change form.method to form.getAttribute * add changeset * normalise form.getAttribute value * remove helper method and use HTMLFormElement.prototype * change form.action to use HTMLFormElement.prototype * revert unneccesary form cloning from runtime/client.js * tidy up Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
1 parent f09ad43 commit 37ed70b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/tidy-plants-relate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: avoid input name clobbering form method check

packages/kit/src/runtime/app/forms.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export function deserialize(result) {
2626

2727
/** @type {import('$app/forms').enhance} */
2828
export function enhance(form, submit = () => {}) {
29-
if (DEV && form.method !== 'post') {
29+
if (
30+
DEV &&
31+
/** @type {HTMLFormElement} */ (HTMLFormElement.prototype.cloneNode.call(form)).method !==
32+
'post'
33+
) {
3034
throw new Error('use:enhance can only be used on <form> fields with method="POST"');
3135
}
3236

0 commit comments

Comments
 (0)