From 05519f79605e86bd2f9f30e01779425864976771 Mon Sep 17 00:00:00 2001 From: paddyobrien Date: Mon, 18 May 2015 18:35:08 +0100 Subject: [PATCH] [BUGFIX release] Fix get with empty string --- packages/ember-metal/lib/property_get.js | 3 ++- packages/ember-metal/tests/accessors/get_path_test.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/ember-metal/lib/property_get.js b/packages/ember-metal/lib/property_get.js index 97afd3cf2f6..2528382d601 100644 --- a/packages/ember-metal/lib/property_get.js +++ b/packages/ember-metal/lib/property_get.js @@ -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 = /^([^\.]+)/; @@ -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); } diff --git a/packages/ember-metal/tests/accessors/get_path_test.js b/packages/ember-metal/tests/accessors/get_path_test.js index 41c1e814d7e..9789c7bf367 100644 --- a/packages/ember-metal/tests/accessors/get_path_test.js +++ b/packages/ember-metal/tests/accessors/get_path_test.js @@ -17,6 +17,7 @@ var moduleOpts = { } }, falseValue: false, + emptyString: '', Wuz: { nar: 'foo' } @@ -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 //