diff --git a/packages/ember-glimmer/tests/integration/syntax/with-test.js b/packages/ember-glimmer/tests/integration/syntax/with-test.js index 48053a68c2a..b8e45eebccc 100644 --- a/packages/ember-glimmer/tests/integration/syntax/with-test.js +++ b/packages/ember-glimmer/tests/integration/syntax/with-test.js @@ -129,6 +129,34 @@ moduleFor('Syntax test: {{#with as}}', class extends TogglingSyntaxConditionalsT this.assertText('No Thing bar'); } + ['@test can access alias of a proxy']() { + this.render(`{{#with proxyThing as |person|}}{{person.name}}{{/with}}`, { + proxyThing: { isTruthy: true, name: 'Tom Dale' } + }); + + this.assertText('Tom Dale'); + + this.runTask(() => this.rerender()); + + this.assertText('Tom Dale'); + + this.runTask(() => set(this.context, 'proxyThing.name', 'Yehuda Katz')); + + this.assertText('Yehuda Katz'); + + this.runTask(() => set(this.context, 'proxyThing.isTruthy', false)); + + this.assertText(''); + + this.runTask(() => set(this.context, 'proxyThing.name', 'Godfrey Chan')); + + this.assertText(''); + + this.runTask(() => set(this.context, 'proxyThing', { isTruthy: true, name: 'Tom Dale' })); + + this.assertText('Tom Dale'); + } + ['@test can access alias of an array']() { this.render(`{{#with arrayThing as |words|}}{{#each words as |word|}}{{word}}{{/each}}{{/with}}`, { arrayThing: emberA(['Hello', ' ', 'world']) diff --git a/packages/ember-htmlbars/lib/hooks/link-render-node.js b/packages/ember-htmlbars/lib/hooks/link-render-node.js index 4351f90c6cc..dd661f355d7 100644 --- a/packages/ember-htmlbars/lib/hooks/link-render-node.js +++ b/packages/ember-htmlbars/lib/hooks/link-render-node.js @@ -87,11 +87,11 @@ function shouldDisplay(predicate, coercer) { let isTruthyVal = read(isTruthy); if (isArray(predicateVal)) { - return lengthVal > 0 ? predicateVal : false; + return lengthVal > 0 ? coercer(predicateVal) : false; } if (typeof isTruthyVal === 'boolean') { - return isTruthyVal; + return isTruthyVal ? coercer(predicateVal) : false; } return coercer(predicateVal);