Skip to content

Commit

Permalink
fix up form serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed Nov 30, 2022
1 parent 51ba383 commit 2b070cb
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/client/packages/idom-client-react/src/event-to-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,19 @@ const elementTransformCategories = {
}
},
hasElements: (element) => {
const result = {};
Object.keys(element).forEach((key) => {
result[key] = serializeDomElement(element.elements[key])
});
return result;
}
const { elements } = element;
const indices = [...Array(elements.length).keys()];
return {
elements: indices.map((index) => serializeDomElement(elements[index])),
};
},
hasName: (element) => {
const { name } = element;
// In some edge cases, "name" may not be a string. For example, in the case of
// `<form><input name="name"></form>`, the "name" attribute of the `<form>` will
// be the `<input>` element.
return typeof name === "string" ? { name } : {};
},
};

function defaultElementTransform(element) {
Expand All @@ -77,6 +84,21 @@ const elementTagCategories = {
hasCurrentTime: ["AUDIO", "VIDEO"],
hasFiles: ["INPUT"],
hasElements: ["FORM"],
hasName: [
"BUTTON",
"FORM",
"FIELDSET",
"IFRAME",
"INPUT",
"KEYGEN",
"OBJECT",
"OUTPUT",
"SELECT",
"TEXTAREA",
"MAP",
"META",
"PARAM",
],
};

const elementTransforms = {};
Expand Down

0 comments on commit 2b070cb

Please sign in to comment.