Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] allow numeric 0 key to work with get helper #15667

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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