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