Skip to content

Commit 1ca6b69

Browse files
committed
Stop using data-model on file inputs as an alternative. It's pointless
1 parent e4bc5eb commit 1ca6b69

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/LiveComponent/assets/dist/live_controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,16 +2825,16 @@ class LiveControllerDefault extends Controller {
28252825
this.updateModelFromElementEvent(target, 'change');
28262826
}
28272827
updateModelFromElementEvent(element, eventName) {
2828-
var _a, _b;
2828+
var _a;
28292829
if (!elementBelongsToThisComponent(element, this.component)) {
28302830
return;
28312831
}
28322832
if (!(element instanceof HTMLElement)) {
28332833
throw new Error('Could not update model for non HTMLElement');
28342834
}
28352835
if (element instanceof HTMLInputElement && element.type === 'file') {
2836-
const key = (_a = element.dataset.model) !== null && _a !== void 0 ? _a : element.name;
2837-
if ((_b = element.files) === null || _b === void 0 ? void 0 : _b.length) {
2836+
const key = element.name;
2837+
if ((_a = element.files) === null || _a === void 0 ? void 0 : _a.length) {
28382838
this.pendingFiles[key] = element.files;
28392839
}
28402840
else if (this.pendingFiles[key]) {

src/LiveComponent/assets/src/live_controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export default class LiveControllerDefault extends Controller<HTMLElement> imple
338338
// file uploads aren't mapped to model,
339339
// but needs to be scheduled for sending
340340
if (element instanceof HTMLInputElement && element.type === 'file') {
341-
const key = element.dataset.model ?? element.name;
341+
const key = element.name;
342342
if (element.files?.length) {
343343
this.pendingFiles[key] = element.files;
344344
} else if (this.pendingFiles[key]) {

0 commit comments

Comments
 (0)