Skip to content

Commit 2155865

Browse files
Lustmoredweaverryan
authored andcommitted
Stop using data-model on file inputs as an alternative. It's pointless
1 parent c74f689 commit 2155865

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
@@ -2827,16 +2827,16 @@ class LiveControllerDefault extends Controller {
28272827
this.updateModelFromElementEvent(target, 'change');
28282828
}
28292829
updateModelFromElementEvent(element, eventName) {
2830-
var _a, _b;
2830+
var _a;
28312831
if (!elementBelongsToThisComponent(element, this.component)) {
28322832
return;
28332833
}
28342834
if (!(element instanceof HTMLElement)) {
28352835
throw new Error('Could not update model for non HTMLElement');
28362836
}
28372837
if (element instanceof HTMLInputElement && element.type === 'file') {
2838-
const key = (_a = element.dataset.model) !== null && _a !== void 0 ? _a : element.name;
2839-
if ((_b = element.files) === null || _b === void 0 ? void 0 : _b.length) {
2838+
const key = element.name;
2839+
if ((_a = element.files) === null || _a === void 0 ? void 0 : _a.length) {
28402840
this.pendingFiles[key] = element.files;
28412841
}
28422842
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)