@sveltejs/kit 1.17.0 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -186,7 +186,9 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
186
186
|
) {
|
|
187
187
|
try {
|
|
188
188
|
query.set('inline', '');
|
|
189
|
-
const mod = await vite.ssrLoadModule(
|
|
189
|
+
const mod = await vite.ssrLoadModule(
|
|
190
|
+
`${decodeURI(url.pathname)}${url.search}${url.hash}`
|
|
191
|
+
);
|
|
190
192
|
styles[dep.url] = mod.default;
|
|
191
193
|
} catch {
|
|
192
194
|
// this can happen with dynamically imported modules, I think
|
package/src/runtime/app/forms.js
CHANGED
|
@@ -28,13 +28,20 @@ function warn_on_access(old_name, new_name, call_location) {
|
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Shallow clone an element, so that we can access e.g. `form.action` without worrying
|
|
33
|
+
* that someone has added an `<input name="action">` (https://github.com/sveltejs/kit/issues/7593)
|
|
34
|
+
* @template {HTMLElement} T
|
|
35
|
+
* @param {T} element
|
|
36
|
+
* @returns {T}
|
|
37
|
+
*/
|
|
38
|
+
function clone(element) {
|
|
39
|
+
return /** @type {T} */ (HTMLElement.prototype.cloneNode.call(element));
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
/** @type {import('$app/forms').enhance} */
|
|
32
43
|
export function enhance(form_element, submit = () => {}) {
|
|
33
|
-
if (
|
|
34
|
-
DEV &&
|
|
35
|
-
/** @type {HTMLFormElement} */ (HTMLFormElement.prototype.cloneNode.call(form_element))
|
|
36
|
-
.method !== 'post'
|
|
37
|
-
) {
|
|
44
|
+
if (DEV && clone(form_element).method !== 'post') {
|
|
38
45
|
throw new Error('use:enhance can only be used on <form> fields with method="POST"');
|
|
39
46
|
}
|
|
40
47
|
|
|
@@ -71,15 +78,25 @@ export function enhance(form_element, submit = () => {}) {
|
|
|
71
78
|
|
|
72
79
|
const action = new URL(
|
|
73
80
|
// We can't do submitter.formAction directly because that property is always set
|
|
74
|
-
// We do cloneNode for avoid DOM clobbering - https://github.com/sveltejs/kit/issues/7593
|
|
75
81
|
event.submitter?.hasAttribute('formaction')
|
|
76
82
|
? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formAction
|
|
77
|
-
:
|
|
78
|
-
.action
|
|
83
|
+
: clone(form_element).action
|
|
79
84
|
);
|
|
80
85
|
|
|
81
86
|
const form_data = new FormData(form_element);
|
|
82
87
|
|
|
88
|
+
if (DEV && clone(form_element).enctype !== 'multipart/form-data') {
|
|
89
|
+
for (const value of form_data.values()) {
|
|
90
|
+
if (value instanceof File) {
|
|
91
|
+
// TODO 2.0: Upgrade to `throw Error`
|
|
92
|
+
console.warn(
|
|
93
|
+
'Your form contains <input type="file"> fields, but is missing the `enctype="multipart/form-data"` attribute. This will lead to inconsistent behavior between enhanced and native forms. For more details, see https://github.com/sveltejs/kit/issues/9819. This will be upgraded to an error in v2.0.'
|
|
94
|
+
);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
83
100
|
const submitter_name = event.submitter?.getAttribute('name');
|
|
84
101
|
if (submitter_name) {
|
|
85
102
|
form_data.append(submitter_name, event.submitter?.getAttribute('value') ?? '');
|