-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Ember.get/Ember.getWithDefault don't work as expected when the key name has "." in it since version 3.8 #18377
Comments
It looks like the original motivation for this was performance: #17166 I think given the perf improvements it's not really possible to revert that commit completely. It may be possible to do a check to see if that property exists in the object first before getting the path, but I feel like that would make the behavior of Short term, I would recommend converting to this: const unionSubContent = {
"id": 1,
"com.linkedin.campaignManager.subtreeNode": {
conversationId: 2
}
}
let value = unionSubContent['com.linkedin.campaignManager.subtreeNode'] || {}; if you need to have more strict nullish defaulting behavior (e.g. only default if null/undefined), you could write a simple function defaultTo(obj, key, defaultValue) {
return (obj[key] === null || obj[key] === undefined) ? defaultValue : obj[key];
}
let value = defaultTo(unionSubContent, 'com.linkedin.campaignManager.subtreeNode', {}); In the future, nullish coalescing will make this much easier: let value = unionSubContent['com.linkedin.campaignManager.subtreeNode'] ?? {}; |
|
Thanks for responding @pzuraq . Ya I already changed to use But given that the usage in template doesn't work as it used to work before, it may come as surprise to users. Eg usage for template |
This does not seem like a valid template snippet, can you double check what you are using? {{leadgen-form-creation
data-test-defaultResponse={{question.typeSpecificQuestionDetails.[com.linkedin.voyager.feed.revenue.PreviewTextQuestionDetails].defaultResponse.string}}
}} |
Pasting from the real example
|
|
We have use case where the key name has "." in it.
Eg:
const unionSubContent = {
"id": 1,
"com.linkedin.campaignManager.subtreeNode": {
conversationId: 2
}
}
getWithDefault(unionSubContent, "com.linkedin.campaignManager.subtreeNode", {});
AND
{{leadgen-form-creation
data-test-defaultResponse={{question.typeSpecificQuestionDetails.[com.linkedin.voyager.feed.revenue.PreviewTextQuestionDetails].defaultResponse.string}}
}}
This worked as expected until 3.7. In 3.8 a commit was checked in to resolve path names correctly
cbbc4c4
This has stopped working since then.
The text was updated successfully, but these errors were encountered: