Skip to content

Commit ceaae0b

Browse files
committed
Don't show any circular reference errors when getDataElementValues is called with a list of data elements that don't have circular references.
This fixes this issue: adobe/reactor-extension-cloud-connector-edge#5.
1 parent 2117c31 commit ceaae0b

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/__tests__/createGetDataElementValues.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,17 @@ describe('function returned by createGetDataElementValues', () => {
4444
expect(getDataElementValue).toHaveBeenCalledWith('de1', context);
4545
});
4646
});
47+
48+
test('sends a cloned dataElementCallStack to getDataElementValue', () => {
49+
const getDataElementValues = createGetDataElementValues(
50+
(dataElementName, { dataElementCallStack }) => {
51+
dataElementCallStack.push(dataElementName);
52+
53+
expect(dataElementCallStack).toStrictEqual([dataElementName]);
54+
}
55+
);
56+
57+
const context = {};
58+
return getDataElementValues(['de1', 'de2'], context);
59+
});
4760
});

src/createGetDataElementValues.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ OF ANY KIND, either express or implied. See the License for the specific languag
99
governing permissions and limitations under the License.
1010
*/
1111

12-
module.exports = (getDataElementValue) => (tokenList, context) =>
13-
Promise.all(
12+
module.exports = (getDataElementValue) => (tokenList, context) => {
13+
const { dataElementCallStack = [] } = context;
14+
15+
return Promise.all(
1416
tokenList.map((t) => {
15-
const { dataElementCallStack = [] } = context;
1617
context.dataElementCallStack = dataElementCallStack.slice();
1718

1819
return getDataElementValue(t, context);
@@ -26,3 +27,4 @@ module.exports = (getDataElementValue) => (tokenList, context) =>
2627

2728
return (name) => zipResults[name];
2829
});
30+
};

0 commit comments

Comments
 (0)