Permalink
Browse files

Fix Ember.setPath when used on Ember.Namespaces

  • Loading branch information...
1 parent 63a3215 commit 7049d29b8abab8f72117e6b99739cda97f7d59fb @ebryn ebryn committed Jun 7, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −1 packages/ember-metal/lib/accessors.js
  2. +7 −0 packages/ember-metal/tests/accessors/setPath_test.js
@@ -248,7 +248,7 @@ Ember.getPath = function(root, path) {
Ember.setPath = function(root, path, value, tolerant) {
var keyName;
- if (IS_GLOBAL.test(root)) {
+ if (typeof root === 'string' && IS_GLOBAL.test(root)) {
value = path;
path = root;
root = null;
@@ -38,6 +38,13 @@ var obj, moduleOpts = {
module('Ember.setPath', moduleOpts);
+test('[Foo, bar] -> Foo.bar', function() {
+ window.Foo = {toString: function() { return 'Foo'; }}; // Behave like an Ember.Namespace
+ Ember.setPath(Foo, 'bar', 'baz');
+ equal(Ember.getPath(Foo, 'bar'), 'baz');
+ delete window.Foo;
@krisselden

krisselden Jun 7, 2012

Owner

delete window.Foo doesn't work in IE

+});
+
// ..........................................................
// LOCAL PATHS
//

0 comments on commit 7049d29

Please sign in to comment.