emberjs / emberjs/ember.js

`get` helper returns `undefined` when the key is a string containing a period

Open
#21,411 3 comments 0 reactions 0 assignees View on GitHub
documentation
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

### 🐞 Describe the Bug
Ember's `get` helper from `@ember/helper` can't handle accessing a value in an object when the key is a string with a dot in it.

E.g. applying `{{ get obj 'some.key' }} to `const obj = { 'some.key': 'some value' };` will return `undefined` rather than `'some value'`.

### 🔬 Minimal Reproduction
See description above and this reproduction on latest Ember: [Repro on Limber](https://limber.glimdown.com/edit?c=JYWwDg9gTgLgBAbzgcwKbwL5wGZQiOAcgAFUQAjVKAegAtUAbMKwgbgCh2BjCAOwGd4qAI5wAvHAAUAQwA0ccgEpxAPjjTxYieQ7tq1OAFV%2BwXsjgBRCi35wABmhh249JlTh84MWsFsRyAFaoXPAAnsCMACa2AK68qAAezCGokXBQqPwxDDD83HyCHoHiiOxwcLzQINIMANKooQBcRJVQ1QxwAG41MaiEsmVEANYNAOrA3gB0kRAwhM2EcRnSXLTS5AyoXT19Axi6PALwXDGC%2BADi6CWS-gHyI6HKYmoIgzBQoaXl5RkwMVC8IoBADaDwAuhxylguNIYKspFQoMpXt90uh-oC4pFUNhTKlIXAMOwiewADwwMhgBiw1AqQYIBAAQks1ighFsDnQzlczCgcAAtHA4olkhS0hksjlCUTyqSwCoAHJVGpwB7bBi9ZoMxxAlrKuoNQgYDCk6jywZylT1T4AdwmtDgM3g3Q1qC1CB1t2GY3t01mRpNZrp9KZcES7w0XGpUAmn2NFvNqOtcDt3kds3VvSkghjZmAuNSimag3KDPzCNEkk9xUID3GUydhGUWJxeMiykWvGxuPikQDFqDnFLoZOZwIOp57kFIuCYrRkswMrglpLcGTqYdTszW1OpnMo5g%2BBQV0nUEaq4ZB4uVy9tZ9Df98dlg9NFPA1IpKiAA&format=gjs)

### 😕 Actual Behavior
Ember's `get` helper returns `undefined` when attempting to access a key that is a string containing a period.

### 🤔 Expected Behavior
I expect the `get` helper to handle accessing keys on objects just like vanilla JavaScript does. Barring that, I expect clear documentation about the different behavior.

### 🌍 Environment

- Ember: 6.12.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.