From f807383f2a0137e97ef0fb402dbc85219c0fcac2 Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Wed, 7 Oct 2020 19:33:50 -0700 Subject: [PATCH] resolved issues raised by hhartle --- src/render/boolean.ts | 5 ++--- test/unit/render/boolean.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/render/boolean.ts b/src/render/boolean.ts index 6366a0984..6c51d63bf 100644 --- a/src/render/boolean.ts +++ b/src/render/boolean.ts @@ -1,13 +1,12 @@ import { Context } from '../context/context' export function isTruthy (val: any, ctx: Context): boolean { - if ((val === null) && ctx && ctx.opts && ctx.opts.jsTruthy ) return false; return !isFalsy(val, ctx) } export function isFalsy (val: any, ctx: Context): boolean { - if(ctx && ctx.opts && ctx.opts.jsTruthy) { - return val == false + if(ctx.opts.jsTruthy) { + return !val } else { return val === false || undefined === val || val === null diff --git a/test/unit/render/boolean.ts b/test/unit/render/boolean.ts index 71c437ec0..4115a4912 100644 --- a/test/unit/render/boolean.ts +++ b/test/unit/render/boolean.ts @@ -58,7 +58,7 @@ describe('boolean jsTruthy', async function () { expect(isTruthy(false, ctx)).to.be.false }) it('null is always falsy', function () { - expect(isTruthy(null, ctx)).to.be.false + expect(isTruthy(null, ctx)).to.be.true }) it('null is always falsy', function () { expect(isTruthy(null, ctx)).to.be.false