Skip to content

Commit

Permalink
[BUGFIX beta] Fix get with empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyobrien committed May 18, 2015
1 parent 003caee commit 0e7ac9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/ember-metal/lib/property_get.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "ember-metal/path_cache";
import { hasPropertyAccessors } from "ember-metal/platform/define_property";
import { symbol } from "ember-metal/utils";
import isNone from 'ember-metal/is_none';

var FIRST_KEY = /^([^\.]+)/;

Expand Down Expand Up @@ -62,7 +63,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 (isNone(obj)) {
return _getPath(obj, keyName);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/ember-metal/tests/accessors/get_path_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var moduleOpts = {
}
},
falseValue: false,
emptyString: '',
Wuz: {
nar: 'foo'
}
Expand Down Expand Up @@ -79,6 +80,10 @@ QUnit.test('[obj, falseValue.notDefined] -> (undefined)', function() {
equal(get(obj, 'falseValue.notDefined'), undefined);
});

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

// ..........................................................
// GLOBAL PATHS TREATED LOCAL WITH GET
//
Expand Down

0 comments on commit 0e7ac9c

Please sign in to comment.