Skip to content

Commit

Permalink
[BUGFIX beta] Ember.get with first part of path chain resolving to …
Browse files Browse the repository at this point in the history
…`null` returns `null` rather than `undefined` (#13449)

(cherry picked from commit 82be117)
  • Loading branch information
Robbie Pitts authored and rwjblue committed May 9, 2016
1 parent fe80d19 commit 9c45b02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/ember-metal/lib/property_get.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function _getPath(root, path) {

for (let i = 0; i < len; i++) {
if (obj == null) {
return obj;
return undefined;
}

obj = get(obj, parts[i]);
Expand Down
13 changes: 9 additions & 4 deletions packages/ember-metal/tests/accessors/get_path_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var moduleOpts = {
emptyString: '',
Wuz: {
nar: 'foo'
}
},
nullValue: null
};
},

Expand Down Expand Up @@ -46,13 +47,17 @@ QUnit.test('[obj, foothis.bar] -> obj.foothis.bar', function() {
});

QUnit.test('[obj, falseValue.notDefined] -> (undefined)', function() {
equal(get(obj, 'falseValue.notDefined'), undefined);
strictEqual(get(obj, 'falseValue.notDefined'), undefined);
});

QUnit.test('[obj, emptyString.length] -> 0', function() {
equal(get(obj, 'emptyString.length'), 0);
});

QUnit.test('[obj, nullValue.notDefined] -> (undefined)', function() {
strictEqual(get(obj, 'nullValue.notDefined'), undefined);
});

// ..........................................................
// GLOBAL PATHS TREATED LOCAL WITH GET
//
Expand All @@ -66,9 +71,9 @@ QUnit.test('[obj, Wuz.nar] -> obj.Wuz.nar', function() {
});

QUnit.test('[obj, Foo] -> (undefined)', function() {
equal(get(obj, 'Foo'), undefined);
strictEqual(get(obj, 'Foo'), undefined);
});

QUnit.test('[obj, Foo.bar] -> (undefined)', function() {
equal(get(obj, 'Foo.bar'), undefined);
strictEqual(get(obj, 'Foo.bar'), undefined);
});
Original file line number Diff line number Diff line change
Expand Up @@ -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');
equal(objectA.lastUnknownProperty, 'unknown');
});

QUnit.test('should get normal properties on standard objects', function() {
Expand Down

0 comments on commit 9c45b02

Please sign in to comment.