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] Fix {{get}} when used on non-objects #1269

Merged
merged 1 commit into from
Feb 15, 2021

Conversation

pzuraq
Copy link
Member

@pzuraq pzuraq commented Feb 12, 2021

Previously, {{get}} would not work on non-object values, even though
they may have had properties (e.g. String.length). This PR fixes this
and makes sure that {{get}} has the same behavior as directly
referencing the property in a template without using {{get}}.

Fixes emberjs/ember.js#19400

Previously, `{{get}}` would not work on non-object values, even though
they may have had properties (e.g. `String.length`). This PR fixes this
and makes sure that `{{get}}` has the same behavior as directly
referencing the property in a template without using `{{get}}`.
@pzuraq pzuraq force-pushed the bugfix/fix-get-helper-on-non-objects branch from 73da183 to 7ebdc05 Compare February 14, 2021 18:25
@rwjblue rwjblue added the bug label Feb 15, 2021
@@ -88,21 +89,17 @@ export default internalHelper((args: VMArguments) => {
() => {
let source = valueForRef(sourceRef);

if (isObject(source)) {
if (isDict(source)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the lazy, this is doing source !== null && source !== undefined

export function isDict<T>(u: T): u is Dict & T {
return u !== null && u !== undefined;
}

@rwjblue rwjblue merged commit 4b69798 into master Feb 15, 2021
@rwjblue rwjblue deleted the bugfix/fix-get-helper-on-non-objects branch February 15, 2021 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Unable to get length of string in v3.25+
2 participants