Skip to content

Commit

Permalink
Merge pull request #19221 from emberjs/bugfix/ensure-mut-works-with-f…
Browse files Browse the repository at this point in the history
…alsy-values

[BUGFIX release] Ensure fn and (mut) work with falsy values
  • Loading branch information
rwjblue authored Oct 21, 2020
2 parents 3a866f9 + 09589f4 commit 4102477
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@ember/-internals/glimmer/lib/helpers/fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function (args: VMArguments) {
if (DEBUG) assertCallbackIsFn(callbackRef);

if (isInvokableRef(callbackRef)) {
let value = args[0] || invocationArgs[0];
let value = args.length > 0 ? args[0] : invocationArgs[0];
return updateRef(callbackRef, value);
} else {
return (fn as Function).call(context, ...args, ...invocationArgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,18 @@ moduleFor(

this.assertText('bar');
}

'@test can be used on the result of `mut` with a falsy value'() {
this.render(`{{this.arg1}}{{stash stashedFn=(fn (mut this.arg1) this.arg2)}}`, {
arg1: 'foo',
arg2: false,
});

this.assertText('foo');

runTask(() => this.stashedFn());

this.assertText('false');
}
}
);

0 comments on commit 4102477

Please sign in to comment.