Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: xml nodes might not be arrays #424

Merged
merged 2 commits into from
Aug 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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