Skip to content

Commit 0098bb0

Browse files
authored
Merge branch 'master' into empty-object
2 parents 48410cb + 5a36a7d commit 0098bb0

File tree

4 files changed

+53
-9
lines changed

4 files changed

+53
-9
lines changed

packages/container/lib/container.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ function instantiate(factory, props, container, fullName) {
535535
obj = factory.create(assign({}, injections, props));
536536

537537
// TODO - remove when Ember reaches v3.0.0
538-
if (!Object.isFrozen(obj) && 'container' in obj) {
538+
if (!Object.isFrozen(obj)) {
539539
injectDeprecatedContainer(obj, container);
540540
}
541541
}
@@ -559,6 +559,7 @@ function factoryInjectionsFor(container, fullName) {
559559

560560
// TODO - remove when Ember reaches v3.0.0
561561
function injectDeprecatedContainer(object, container) {
562+
if ('container' in object) { return; }
562563
Object.defineProperty(object, 'container', {
563564
configurable: true,
564565
enumerable: false,
@@ -695,8 +696,9 @@ class FactoryManager {
695696
` an invalid module export.`);
696697
}
697698

698-
if (this.class.prototype) {
699-
injectDeprecatedContainer(this.class.prototype, this.container);
699+
let prototype = this.class.prototype;
700+
if (prototype) {
701+
injectDeprecatedContainer(prototype, this.container);
700702
}
701703

702704
return this.class.create(props);

packages/ember-metal/lib/meta.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -276,26 +276,30 @@ export class Meta {
276276

277277
_forEachIn(key, subkey, fn) {
278278
let pointer = this;
279-
let seen = Object.create(null);
280-
let calls = [];
279+
let seen;
280+
let calls;
281281
while (pointer !== undefined) {
282282
let map = pointer[key];
283283
if (map) {
284+
seen = seen || new EmptyObject();
284285
let innerMap = map[subkey];
285286
if (innerMap) {
286287
for (let innerKey in innerMap) {
287288
if (!seen[innerKey]) {
288289
seen[innerKey] = true;
290+
calls = calls || [];
289291
calls.push([innerKey, innerMap[innerKey]]);
290292
}
291293
}
292294
}
293295
}
294296
pointer = pointer.parent;
295297
}
296-
for (let i = 0; i < calls.length; i++) {
297-
let [innerKey, value] = calls[i];
298-
fn(innerKey, value);
298+
if (calls) {
299+
for (let i = 0; i < calls.length; i++) {
300+
let [innerKey, value] = calls[i];
301+
fn(innerKey, value);
302+
}
299303
}
300304
}
301305

packages/ember-routing/lib/system/route.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ let Route = EmberObject.extend(ActionHandler, Evented, {
17011701
`_super`:
17021702
17031703
```app/routes/photos.js
1704-
import Ember from 'ebmer';
1704+
import Ember from 'ember';
17051705
17061706
export default Ember.Route.extend({
17071707
model() {

packages/ember-runtime/lib/mixins/container_proxy.js

+38
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,44 @@ let containerProxyMixin = {
148148
};
149149

150150
if (isFeatureEnabled('ember-factory-for')) {
151+
/**
152+
Given a fullName return a factory manager.
153+
154+
This method returns a manager which can be used for introspection of the
155+
factory's class or for the creation of factory instances with initial
156+
properties. The manager is an object with the following properties:
157+
158+
* `class` - The registered or resolved class.
159+
* `create` - A function that will create an instance of the class with
160+
any dependencies injected.
161+
162+
For example:
163+
164+
```javascript
165+
let owner = Ember.getOwner(otherInstance);
166+
// the owner is commonly the `applicationInstance`, and can be accessed via
167+
// an instance initializer.
168+
169+
let factory = owner.factoryFor('service:bespoke');
170+
171+
factory.class;
172+
// The registered or resolved class. For example when used with an Ember-CLI
173+
// app, this would be the default export from `app/services/bespoke.js`.
174+
175+
let instance = factory.create({
176+
someProperty: 'an initial property value'
177+
});
178+
// Create an instance with any injections and the passed options as
179+
// initial properties.
180+
```
181+
182+
@public
183+
@class ContainerProxyMixin
184+
@method factoryFor
185+
@param {String} fullName
186+
@param {Object} options
187+
@return {FactoryManager}
188+
*/
151189
containerProxyMixin.factoryFor = function ContainerProxyMixin_factoryFor(fullName, options = {}) {
152190
return this.__container__.factoryFor(fullName, options);
153191
};

0 commit comments

Comments
 (0)