Skip to content

Commit

Permalink
Merge pull request #12996 from spencer516/with-array
Browse files Browse the repository at this point in the history
[bugfix BETA] Fixes 12995 #with array yields true
  • Loading branch information
rwjblue committed Feb 23, 2016
2 parents b8eda40 + 626339c commit d1d50d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions packages/ember-glimmer/tests/integration/syntax/with-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,29 @@ moduleFor('Syntax test: {{#with as}}', class extends SharedConditionalsTest{
this.assertText('No Thing bar');
}

['@test can access alias of an array']() {
this.render(`{{#with arrayThing as |thing|}}{{#each thing as |value|}}{{value}}{{/each}}{{/with}}`, {
arrayThing: ['a', 'b', 'c', 'd']
});

this.assertText('abcd');

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

this.assertText('abcd');
}

['@test empty arrays yield inverse']() {
this.render(`{{#with arrayThing as |thing|}}{{thing}}{{else}}Empty Array{{/with}}`, {
arrayThing: []
});

this.assertText('Empty Array');

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

this.assertText('Empty Array');
}
}, BASIC_TRUTHY_TESTS, BASIC_FALSY_TESTS);

moduleFor('Syntax test: Multiple {{#with as}} helpers', class extends RenderingTest {
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-htmlbars/lib/hooks/link-render-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function shouldDisplay(predicate, coercer) {
let isTruthyVal = read(isTruthy);

if (isArray(predicateVal)) {
return lengthVal > 0;
return lengthVal > 0 ? predicateVal : false;
}

if (typeof isTruthyVal === 'boolean') {
Expand Down

0 comments on commit d1d50d1

Please sign in to comment.