Skip to content

Commit 941b692

Browse files
committed
Add test to ensure name property exists on inputs
1 parent 258c86a commit 941b692

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/js/packages/event-to-object/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function classToObject(x: any, maxDepth: number): object {
157157
}
158158

159159
// Explicitly include common input properties if they exist
160-
const extraProps = ["value", "checked", "files", "type"];
160+
const extraProps = ["value", "checked", "files", "type", "name"];
161161
for (const prop of extraProps) {
162162
if (
163163
x &&

src/js/packages/event-to-object/tests/event-to-object.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,3 +464,23 @@ test("excludes 'on' properties when missing", () => {
464464
expect(converted.target.onclick).toBeUndefined();
465465
expect(converted.target.oncustom).toBeUndefined();
466466
});
467+
468+
test("includes name property for inputs", () => {
469+
const input = document.createElement("input");
470+
input.name = "test-input";
471+
input.value = "test-value";
472+
473+
const event = new window.Event("change");
474+
Object.defineProperty(event, "target", {
475+
value: input,
476+
enumerable: true,
477+
writable: true,
478+
});
479+
480+
checkEventConversion(event, {
481+
target: {
482+
name: "test-input",
483+
value: "test-value",
484+
},
485+
});
486+
});

0 commit comments

Comments
 (0)