remove unnecessary function expression in prepForXml
This commit is contained in:
@ -23,13 +23,11 @@ export abstract class XmlComponent extends BaseXmlComponent {
|
|||||||
.filter((comp) => comp !== undefined); // Exclude undefined
|
.filter((comp) => comp !== undefined); // Exclude undefined
|
||||||
// If we only have a single IXmlableObject in our children array and it
|
// If we only have a single IXmlableObject in our children array and it
|
||||||
// represents our attributes, use the object itself as our children to
|
// represents our attributes, use the object itself as our children to
|
||||||
// avoid an unneeded XML close element. (Note: We have to use this
|
// avoid an unneeded XML close element.
|
||||||
// function to get typescript to allow our check.)
|
|
||||||
// Additionally, if the array is empty, use an empty object as our
|
// Additionally, if the array is empty, use an empty object as our
|
||||||
// children in order to get an empty XML element generated.
|
// children in order to get an empty XML element generated.
|
||||||
const onlyAttrs = (c) => typeof c === "object" && c._attr;
|
|
||||||
return {
|
return {
|
||||||
[this.rootKey]: children.length ? (children.length === 1 && onlyAttrs(children[0]) ? children[0] : children) : EMPTY_OBJECT,
|
[this.rootKey]: children.length ? (children.length === 1 && children[0]?._attr ? children[0] : children) : EMPTY_OBJECT,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user