jmurphyau / ember-truth-helpers

Ember HTMLBars Helpers for {{if}} & {{unless}}: not, and, or, eq & is-array
MIT License
706 stars 95 forks source link

`and` returns non-boolean value rather than converting it (which breaks default value logic) #202

Open emattias opened 11 months ago

emattias commented 11 months ago

The and helper returns the value as it is if its falsy (rather than converting it to a boolean first) here: https://github.com/jmurphyau/ember-truth-helpers/blob/master/packages/ember-truth-helpers/src/helpers/and.ts#L33

This results in some unexpected behavior, see twiddle

CleanShot 2023-10-10 at 15 15 31@2x

Suggestion

Can we change that line to:

return truthConvert(params[i]);

or

return !!params[i];

So that and returns false rather than undefined when it gets undefined. That would result in a more expected behavior IMO.