Skip to content

Commit 091024e

Browse files
committed
allow numeric 0 key to work with get helper
1 parent b27344a commit 091024e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/ember-glimmer/lib/helpers/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class GetHelperReference extends CachedReference {
9090
let path = this.lastPath = this.pathReference.value();
9191

9292
if (path !== lastPath) {
93-
if (path) {
93+
if (path !== undefined && path !== null) {
9494
let pathType = typeof path;
9595

9696
if (pathType === 'string') {

packages/ember-glimmer/tests/integration/helpers/get-test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ moduleFor('Helpers test: {{get}}', class extends RenderingTest {
7575
this.assertText('[First][Second][Third]');
7676
}
7777

78+
79+
['@test should be able to get an array value with numeric keys']() {
80+
this.render(`{{#each numbers as |num index|}}[{{get numbers index}}]{{/each}}`, {
81+
numbers: [1, 2, 3],
82+
});
83+
84+
this.assertText('[1][2][3]');
85+
86+
this.runTask(() => this.rerender());
87+
88+
this.assertText('[1][2][3]');
89+
90+
this.runTask(() => set(this.context, 'numbers', [3, 2, 1]));
91+
92+
this.assertText('[3][2][1]');
93+
}
94+
7895
['@test should be able to get an object value with a bound/dynamic key']() {
7996
this.render(`[{{get colors key}}] [{{if true (get colors key)}}]`, {
8097
colors: { apple: 'red', banana: 'yellow' },

0 commit comments

Comments
 (0)