Skip to content

Commit

Permalink
[BUGFIX beta] allow numeric 0 key to work with get helper
Browse files Browse the repository at this point in the history
  • Loading branch information
bekzod committed Sep 14, 2017
1 parent b27344a commit c79701c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-glimmer/lib/helpers/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class GetHelperReference extends CachedReference {
let path = this.lastPath = this.pathReference.value();

if (path !== lastPath) {
if (path) {
if (path !== undefined && path !== null) {
let pathType = typeof path;

if (pathType === 'string') {
Expand Down
17 changes: 17 additions & 0 deletions packages/ember-glimmer/tests/integration/helpers/get-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ moduleFor('Helpers test: {{get}}', class extends RenderingTest {
this.assertText('[First][Second][Third]');
}


['@test should be able to get an array value with numeric keys']() {
this.render(`{{#each numbers as |num index|}}[{{get numbers index}}]{{/each}}`, {
numbers: [1, 2, 3],
});

this.assertText('[1][2][3]');

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

this.assertText('[1][2][3]');

this.runTask(() => set(this.context, 'numbers', [3, 2, 1]));

this.assertText('[3][2][1]');
}

['@test should be able to get an object value with a bound/dynamic key']() {
this.render(`[{{get colors key}}] [{{if true (get colors key)}}]`, {
colors: { apple: 'red', banana: 'yellow' },
Expand Down

0 comments on commit c79701c

Please sign in to comment.