import Ember from 'ember';
import FakeOwner from './fake-owner';

let hasGetOwner = !!Ember.getOwner;

export default function(object) {
  let owner;

  if (hasGetOwner) {
    owner = Ember.getOwner(object);
  }

  if (!owner && object.container) {
    owner = new FakeOwner(object);
  }

  return owner;
};

import Ember from 'ember';
import FakeOwner from './fake-owner';

let getOwner;

if (Ember.getOwner) {
  getOwner = Ember.getOwner;
} else {
  getOwner = function(object) {
    return new FakeOwner(object);
  };
}

export default getOwner;

--- 
+++ 
@@ -1,14 +1,18 @@
 import Ember from 'ember';
 import FakeOwner from './fake-owner';
 
-let getOwner;
+let hasGetOwner = !!Ember.getOwner;
 
-if (Ember.getOwner) {
-  getOwner = Ember.getOwner;
-} else {
-  getOwner = function(object) {
-    return new FakeOwner(object);
-  };
-}
+export default function(object) {
+  let owner;
 
-export default getOwner;
+  if (hasGetOwner) {
+    owner = Ember.getOwner(object);
+  }
+
+  if (!owner && object.container) {
+    owner = new FakeOwner(object);
+  }
+
+  return owner;
+};
Allow to function when `Ember.getOwner` is present but owner is not set.
