-
-
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 beta] Ember.get
with first part of path chain resolving to null
returns null
rather than undefined
#13449
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,8 +129,8 @@ QUnit.test('should return null when property value is null on Ember.Observable', | |
}); | ||
|
||
QUnit.test('should call unknownProperty when value is undefined on Ember.Observable', function() { | ||
equal(get(object, 'unknown'), 'unknown'); | ||
equal(object.lastUnknownProperty, 'unknown'); | ||
equal(get(objectA, 'unknown'), 'unknown'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would fail if only the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh. Good catch! |
||
equal(objectA.lastUnknownProperty, 'unknown'); | ||
}); | ||
|
||
QUnit.test('should get normal properties on standard objects', function() { | ||
|
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.
we only want to call get on object like things, this should do if (!isObjectLike(obj)) { return undefined; }
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.
To be specific, I would check falsy, and that the typeof was 'string', 'object', 'function' but at a minimum this can simply check falsy. I'm sure the
obj == null
check was a bad fix to this sometimes returning false vs undefined.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.
Falsey alone won't work because of empty strings, e.g.
Ember.get({ foo: "" }, 'foo.length')
should be 0 not undefined. (Can you add a test for this one @robbiepitts? if there isn't one already)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.
Confirm, using get for string.length seems super lame.