diff --git a/core/src/template-string/functions.ts b/core/src/template-string/functions.ts index 7738c0c24e..4b4241c4b0 100644 --- a/core/src/template-string/functions.ts +++ b/core/src/template-string/functions.ts @@ -479,11 +479,13 @@ export function callHelperFunction({ const resolvedArgs: any[] = [] for (const arg of args) { - if (arg._error) { + // arg can be null here because some helpers allow nulls as valid args + if (arg && arg._error) { return arg } - if (arg && arg.resolved) { + // allow nulls as valid arg values + if (arg && arg.resolved !== undefined) { resolvedArgs.push(arg.resolved) } else { resolvedArgs.push(arg) diff --git a/core/test/unit/src/template-string.ts b/core/test/unit/src/template-string.ts index bfb0c55e4b..57b56b31fa 100644 --- a/core/test/unit/src/template-string.ts +++ b/core/test/unit/src/template-string.ts @@ -1107,6 +1107,20 @@ describe("resolveTemplateString", () => { }) }) + context("isEmpty", () => { + context("allows nulls", () => { + it("resolves null as 'true'", () => { + const res = resolveTemplateString("${isEmpty(null)}", new TestContext({})) + expect(res).to.be.true + }) + + it("resolves references to null as 'true'", () => { + const res = resolveTemplateString("${isEmpty(a)}", new TestContext({ a: null })) + expect(res).to.be.true + }) + }) + }) + context("slice", () => { it("allows numeric indices", () => { const res = resolveTemplateString("${slice(foo, 0, 3)}", new TestContext({ foo: "abcdef" }))