Skip to content

Commit

Permalink
fix: xml nodes might not be arrays (#424)
Browse files Browse the repository at this point in the history
Co-authored-by: Willie Ruemmele <[email protected]>
  • Loading branch information
2 people authored and AnanyaJha committed Aug 19, 2021
1 parent 8f73e7a commit ca05908
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/convert/convertContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { JsToXml } from './streams';
import { META_XML_SUFFIX, XML_NS_KEY, XML_NS_URL } from '../common';
import { getString, JsonArray, JsonMap } from '@salesforce/ts-types';
import { ComponentSet } from '../collections';
import { normalizeToArray } from '../utils/collections';
import { RecompositionStrategy } from '../registry/types';
import { isEmpty } from '@salesforce/kit';

Expand Down Expand Up @@ -89,7 +90,8 @@ class RecompositionFinalizer extends ConvertTransactionFinalizer<RecompositionSt
parent[groupName] = [];
}

const group = parent[groupName] as JsonArray;
// it might be an object and not an array. Example: custom object with a Field property containing a single field
const group = normalizeToArray(parent[groupName]) as JsonArray;

group.push(childContents);
}
Expand Down Expand Up @@ -306,8 +308,7 @@ class NonDecompositionFinalizer extends ConvertTransactionFinalizer<NonDecomposi
parent[groupName] = [];
}

const group = parent[groupName] as JsonArray;

const group = normalizeToArray(parent[groupName]) as JsonArray;
group.push(child);
}

Expand Down

0 comments on commit ca05908

Please sign in to comment.