diff --git a/src/client/packages/idom-client-react/src/event-to-object.js b/src/client/packages/idom-client-react/src/event-to-object.js index b11e65366..057f344e5 100644 --- a/src/client/packages/idom-client-react/src/event-to-object.js +++ b/src/client/packages/idom-client-react/src/event-to-object.js @@ -49,6 +49,13 @@ const elementTransformCategories = { return {}; } }, + hasElements: (element) => { + const result = {}; + Object.keys(element).forEach((key) => { + result[key] = serializeDomElement(element.elements[key]) + }); + return result; + } }; function defaultElementTransform(element) { @@ -69,6 +76,7 @@ const elementTagCategories = { ], hasCurrentTime: ["AUDIO", "VIDEO"], hasFiles: ["INPUT"], + hasElements: ["FORM"], }; const elementTransforms = {}; diff --git a/src/client/packages/idom-client-react/tests/event-to-object.test.js b/src/client/packages/idom-client-react/tests/event-to-object.test.js index 3dd3852fd..edd81c388 100644 --- a/src/client/packages/idom-client-react/tests/event-to-object.test.js +++ b/src/client/packages/idom-client-react/tests/event-to-object.test.js @@ -76,6 +76,11 @@ const allTargetData = { tagName, output: { target: { currentTime: allTargetData.currentTime } }, })), + ...["FORM"].map((tagName) => ({ + case: `adds 'value' attribute for ${tagName} element`, + tagName, + output: { target: { value: allTargetData.value } }, + })), ].forEach((expectation) => { test(`serializeEvent() ${expectation.case}`, () => { const eventData = { @@ -113,6 +118,7 @@ const allEventData = { clientX: "clientX", clientY: "clientY", ctrlKey: "ctrlKey", + form: "form", metaKey: "metaKey", pageX: "pageX", pageY: "pageY",