From 0539f1a4299ddb2eb8dbc9de3c4a001eec4cf163 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 14 Oct 2021 13:04:57 +0100 Subject: [PATCH] Remove optional chaining from string-templates --- packages/string-templates/src/helpers/Helper.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/string-templates/src/helpers/Helper.js b/packages/string-templates/src/helpers/Helper.js index 3dc70ba0dc..d963c87158 100644 --- a/packages/string-templates/src/helpers/Helper.js +++ b/packages/string-templates/src/helpers/Helper.js @@ -8,7 +8,10 @@ class Helper { register(handlebars) { // wrap the function so that no helper can cause handlebars to break handlebars.registerHelper(this.name, (value, info) => { - const context = info?.data?.root || {} + let context = {} + if (info && info.data && info.data.root) { + context = info.data.root + } const result = this.fn(value, context) if (result == null) { return this.useValueFallback ? value : null