-
-
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
[BUGFIX release] Fix get with empty string #11205
[BUGFIX release] Fix get with empty string #11205
Conversation
@@ -62,7 +62,7 @@ export function get(obj, keyName) { | |||
Ember.assert(`Cannot call get with ${keyName} key.`, !!keyName); | |||
Ember.assert(`Cannot call get with '${keyName}' on an undefined object.`, obj !== undefined); | |||
|
|||
if (!obj) { | |||
if (!obj && typeof obj !== 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an isNone
(via import isNone from 'ember-metal/is_none';
) check here would be better than specifically checking for strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yes that's much neater.
ece32a5
to
0e7ac9c
Compare
Looks good. @mixonic / @stefanpenner / @krisselden - Would one of y'all mind reviewing also? |
looks ok, is this a regression? This seems like it has been this behavior for some time. |
It looks to be a regression in 1.12, see http://emberjs.jsbin.com/peposiconi/1/edit?html,js,console,output |
@stefanpenner - This was introduced by #3852 which initially landed in 1.12 (it sat as a PR for a very long time). The behavior prior to #3852 was to check Short version: yes, it is a regression in 1.12 that was not present in prior versions. |
Oh also, should this be [BUGFIX release], I found this while working on a 1.12 upgrade and this behaviour would prevent me from continuing that upgrade. |
|
0e7ac9c
to
0dab9aa
Compare
ok, updated to |
0dab9aa
to
824cac8
Compare
824cac8
to
05519f7
Compare
👍 |
[BUGFIX release] Fix get with empty string
@paddyobrien - Thank you! |
Fixes #11204
The change introduced here: 1a3dde2#diff-1b9682e6b936bfe3101e35ff6e574957R61 introduced this issue because it assumed that a falsey
obj
always meant it was not present. However ifobj
is a string it can be both falsey and present.