dist/ember-runtime.js in ember-source-2.2.1 vs dist/ember-runtime.js in ember-source-2.3.0.beta.1
- old
+ new
@@ -4,11 +4,11 @@
* @copyright Copyright 2011-2015 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
- * @version 2.2.1
+ * @version 2.3.0-beta.1
*/
var enifed, requireModule, require, requirejs, Ember;
var mainContext = this;
@@ -41,39 +41,46 @@
};
requirejs = require = requireModule = function(name) {
return internalRequire(name, null);
}
+ require['default'] = require;
+ function missingModule(name, referrerName) {
+ if (referrerName) {
+ throw new Error('Could not find module ' + name + ' required by: ' + referrerName);
+ } else {
+ throw new Error('Could not find module ' + name);
+ }
+ }
+
function internalRequire(name, referrerName) {
var exports = seen[name];
if (exports !== undefined) {
return exports;
}
exports = seen[name] = {};
if (!registry[name]) {
- if (referrerName) {
- throw new Error('Could not find module ' + name + ' required by: ' + referrerName);
- } else {
- throw new Error('Could not find module ' + name);
- }
+ missingModule(name, referrerName);
}
var mod = registry[name];
var deps = mod.deps;
var callback = mod.callback;
- var reified = [];
var length = deps.length;
+ var reified = new Array(length);;
for (var i = 0; i < length; i++) {
if (deps[i] === 'exports') {
- reified.push(exports);
+ reified[i] = exports;
+ } else if (deps[i] === 'require') {
+ reified[i] = require;
} else {
- reified.push(internalRequire(deps[i], name));
+ reified[i] = internalRequire(deps[i], name);
}
}
callback.apply(this, reified);
@@ -1180,11 +1187,11 @@
function clearItems(item) {
clearTimeout(item[2]);
}
});
-enifed('container/container', ['exports', 'ember-metal/core', 'ember-metal/debug', 'ember-metal/dictionary', 'ember-metal/features'], function (exports, _emberMetalCore, _emberMetalDebug, _emberMetalDictionary, _emberMetalFeatures) {
+enifed('container/container', ['exports', 'ember-metal/core', 'ember-metal/debug', 'ember-metal/dictionary', 'ember-metal/features', 'container/owner', 'ember-runtime/mixins/container_proxy'], function (exports, _emberMetalCore, _emberMetalDebug, _emberMetalDictionary, _emberMetalFeatures, _containerOwner, _emberRuntimeMixinsContainer_proxy) {
'use strict';
/**
A container used to instantiate and cache objects.
@@ -1198,18 +1205,30 @@
@private
@class Container
*/
function Container(registry, options) {
this.registry = registry;
+ this.owner = options && options.owner ? options.owner : null;
this.cache = _emberMetalDictionary.default(options && options.cache ? options.cache : null);
this.factoryCache = _emberMetalDictionary.default(options && options.factoryCache ? options.factoryCache : null);
this.validationCache = _emberMetalDictionary.default(options && options.validationCache ? options.validationCache : null);
+
+ if (_emberMetalFeatures.default('ember-container-inject-owner')) {
+ this._fakeContainerToInject = _emberRuntimeMixinsContainer_proxy.buildFakeContainerWithDeprecations(this);
+ }
}
Container.prototype = {
/**
@private
+ @property owner
+ @type Object
+ */
+ owner: null,
+
+ /**
+ @private
@property registry
@type Registry
@since 1.11.0
*/
registry: null,
@@ -1344,21 +1363,21 @@
function areInjectionsDynamic(injections) {
return !!injections._dynamic;
}
- function buildInjections(container) {
+ function buildInjections() /* container, ...injections */{
var hash = {};
if (arguments.length > 1) {
- var injectionArgs = Array.prototype.slice.call(arguments, 1);
+ var container = arguments[0];
var injections = [];
var injection;
- for (var i = 0, l = injectionArgs.length; i < l; i++) {
- if (injectionArgs[i]) {
- injections = injections.concat(injectionArgs[i]);
+ for (var i = 1, l = arguments.length; i < l; i++) {
+ if (arguments[i]) {
+ injections = injections.concat(arguments[i]);
}
}
container.registry.validateInjections(injections);
@@ -1401,10 +1420,18 @@
var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections);
factoryInjections._toString = registry.makeToString(factory, fullName);
var injectedFactory = factory.extend(injections);
+
+ // TODO - remove all `container` injections when Ember reaches v3.0.0
+ if (_emberMetalFeatures.default('ember-container-inject-owner')) {
+ injectDeprecatedContainer(injectedFactory.prototype, container);
+ } else {
+ injectedFactory.prototype.container = container;
+ }
+
injectedFactory.reopenClass(factoryInjections);
if (factory && typeof factory._onLookup === 'function') {
factory._onLookup(fullName);
}
@@ -1422,12 +1449,13 @@
var splitName = fullName.split(':');
var type = splitName[0];
var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName));
injections._debugContainerKey = fullName;
- injections.container = container;
+ _containerOwner.setOwner(injections, container.owner);
+
return injections;
}
function factoryInjectionsFor(container, fullName) {
var registry = container.registry;
@@ -1463,22 +1491,55 @@
container.registry.validateInjections(lazyInjections);
}
validationCache[fullName] = true;
+ var obj = undefined;
+
if (typeof factory.extend === 'function') {
// assume the factory was extendable and is already injected
- return factory.create();
+ obj = factory.create();
} else {
// assume the factory was extendable
// to create time injections
// TODO: support new'ing for instantiation and merge injections for pure JS Functions
- return factory.create(injectionsFor(container, fullName));
+ var injections = injectionsFor(container, fullName);
+
+ // Ensure that a container is available to an object during instantiation.
+ // TODO - remove when Ember reaches v3.0.0
+ if (_emberMetalFeatures.default('ember-container-inject-owner')) {
+ // This "fake" container will be replaced after instantiation with a
+ // property that raises deprecations every time it is accessed.
+ injections.container = container._fakeContainerToInject;
+ } else {
+ injections.container = container;
+ }
+
+ obj = factory.create(injections);
+
+ // TODO - remove when Ember reaches v3.0.0
+ if (_emberMetalFeatures.default('ember-container-inject-owner')) {
+ injectDeprecatedContainer(obj, container);
+ }
}
+
+ return obj;
}
}
+ // TODO - remove when Ember reaches v3.0.0
+ function injectDeprecatedContainer(object, container) {
+ Object.defineProperty(object, 'container', {
+ configurable: true,
+ enumerable: false,
+ get: function () {
+ _emberMetalDebug.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' });
+ return container;
+ }
+ });
+ }
+
function eachDestroyable(container, callback) {
var cache = container.cache;
var keys = Object.keys(cache);
var key, value;
@@ -1514,23 +1575,83 @@
member.destroy();
}
}
}
- // Once registry / container reform is enabled, we no longer need to expose
- // Container#_registry, since Container itself will be fully private.
- if (!_emberMetalFeatures.default('ember-registry-container-reform')) {
- Object.defineProperty(Container.prototype, '_registry', {
- configurable: true,
- enumerable: false,
- get: function () {
- return this.registry;
+ exports.default = Container;
+});
+enifed('container/owner', ['exports', 'ember-metal/symbol'], function (exports, _emberMetalSymbol) {
+ /**
+ @module ember
+ @submodule ember-runtime
+ */
+
+ 'use strict';
+
+ exports.getOwner = getOwner;
+ exports.setOwner = setOwner;
+ var OWNER = _emberMetalSymbol.default('OWNER');
+
+ exports.OWNER = OWNER;
+ /**
+ Framework objects in an Ember application (components, services, routes, etc.)
+ are created via a factory and dependency injection system. Each of these
+ objects is the responsibility of an "owner", which handled its
+ instantiation and manages its lifetime.
+
+ `getOwner` fetches the owner object responsible for an instance. This can
+ be used to lookup or resolve other class instances, or register new factories
+ into the owner.
+
+ For example, this component dynamically looks up a service based on the
+ `audioType` passed as an attribute:
+
+ ```
+ // app/components/play-audio.js
+ import Ember from 'ember';
+
+ // Usage:
+ //
+ // {{play-audio audioType=model.audioType audioFile=model.file}}
+ //
+ export default Ember.Component.extend({
+ audioService: Ember.computed('audioType', function() {
+ let owner = Ember.getOwner(this);
+ return owner.lookup(`service:${this.get('audioType')}`);
+ }),
+ click() {
+ let player = this.get('audioService');
+ player.play(this.get('audioFile'));
}
});
+ ```
+
+ @method getOwner
+ @param {Object} object A object with an owner.
+ @return {Object} an owner object.
+ @for Ember
+ @public
+ */
+
+ function getOwner(object) {
+ return object[OWNER];
}
- exports.default = Container;
+ /**
+ `setOwner` forces a new owner on a given object instance. This is primarily
+ useful in some testing cases.
+
+ @method setOwner
+ @param {Object} object A object with an owner.
+ @return {Object} an owner object.
+ @for Ember
+ @public
+ */
+
+ function setOwner(object, owner) {
+ object[OWNER] = owner;
+ }
});
enifed('container/registry', ['exports', 'ember-metal/debug', 'ember-metal/dictionary', 'ember-metal/assign', 'container/container'], function (exports, _emberMetalDebug, _emberMetalDictionary, _emberMetalAssign, _containerContainer) {
'use strict';
var VALID_FULL_NAME_REGEXP = /^[^:]+.+:[^:]+$/;
@@ -2190,11 +2311,11 @@
return registry.resolve(fullName) !== undefined;
}
exports.default = Registry;
});
-enifed('container', ['exports', 'ember-metal/core', 'container/registry', 'container/container'], function (exports, _emberMetalCore, _containerRegistry, _containerContainer) {
+enifed('container', ['exports', 'ember-metal/core', 'container/registry', 'container/container', 'container/owner'], function (exports, _emberMetalCore, _containerRegistry, _containerContainer, _containerOwner) {
'use strict';
/*
Public api for the container is still in flux.
The public api, specified on the application namespace should be considered the stable api.
@@ -2213,10 +2334,12 @@
_emberMetalCore.default.MODEL_FACTORY_INJECTIONS = !!_emberMetalCore.default.ENV.MODEL_FACTORY_INJECTIONS;
}
exports.Registry = _containerRegistry.default;
exports.Container = _containerContainer.default;
+ exports.getOwner = _containerOwner.getOwner;
+ exports.setOwner = _containerOwner.setOwner;
});
enifed('ember-metal/alias', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalUtils, _emberMetalMeta, _emberMetalDependent_keys) {
'use strict';
exports.default = alias;
@@ -2988,11 +3111,11 @@
function removeChainWatcher(obj, keyName, node) {
if (!isObject(obj)) {
return;
}
- var m = obj.__ember_meta__;
+ var m = _emberMetalMeta.peekMeta(obj);
if (!m || !m.readableChainWatchers()) {
return;
}
@@ -3036,11 +3159,11 @@
function lazyGet(obj, key) {
if (!obj) {
return;
}
- var meta = obj['__ember_meta__'];
+ var meta = _emberMetalMeta.peekMeta(obj);
// check if object meant only to be a prototype
if (meta && meta.proto === obj) {
return;
}
@@ -3242,11 +3365,11 @@
}
};
function finishChains(obj) {
// We only create meta if we really have to
- var m = obj.__ember_meta__;
+ var m = _emberMetalMeta.peekMeta(obj);
if (m) {
m = _emberMetalMeta.meta(obj);
// finish any current chains node watchers that reference obj
var chainWatchers = m.readableChainWatchers();
@@ -3558,11 +3681,11 @@
if (this._volatile || this._suspended === obj) {
return;
}
// don't create objects just to invalidate
- var meta = obj.__ember_meta__;
+ var meta = _emberMetalMeta.peekMeta(obj);
if (!meta || meta.source !== obj) {
return;
}
var cache = meta.readableCache();
@@ -3782,26 +3905,24 @@
/**
This helper returns a new property descriptor that wraps the passed
computed property function. You can use this helper to define properties
with mixins or via `Ember.defineProperty()`.
- If you pass function as argument - it will be used as getter.
- You can pass hash with two functions - instead of single function - as argument to provide both getter and setter.
+ If you pass a function as an argument, it will be used as a getter. A computed
+ property defined in this way might look like this:
- The `get` function should accept two parameters, `key` and `value`. If `value` is not
- undefined you should set the `value` first. In either case return the
- current value of the property.
-
- A computed property defined in this way might look like this:
-
```js
let Person = Ember.Object.extend({
- firstName: 'Betty',
- lastName: 'Jones',
+ init() {
+ this._super(...arguments);
+ this.firstName = 'Betty';
+ this.lastName = 'Jones';
+ },
+
fullName: Ember.computed('firstName', 'lastName', function() {
- return this.get('firstName') + ' ' + this.get('lastName');
+ return `${this.get('firstName')} ${this.get('lastName')}`;
})
});
let client = Person.create();
@@ -3809,18 +3930,49 @@
client.set('lastName', 'Fuller');
client.get('fullName'); // 'Betty Fuller'
```
+ You can pass a hash with two functions, `get` and `set`, as an
+ argument to provide both a getter and setter:
+
+ ```js
+ let Person = Ember.Object.extend({
+ init() {
+ this._super(...arguments);
+
+ this.firstName = 'Betty';
+ this.lastName = 'Jones';
+ },
+
+ fullName: Ember.computed({
+ get(key) {
+ return `${this.get('firstName')} ${this.get('lastName')}`;
+ },
+ set(key, value) {
+ let [firstName, lastName] = value.split(/\s+/);
+ this.setProperties({ firstName, lastName });
+ return value;
+ }
+ });
+ })
+
+ let client = Person.create();
+ client.get('firstName'); // 'Betty'
+
+ client.set('fullName', 'Carroll Fuller');
+ client.get('firstName'); // 'Carroll'
+ ```
+
+ The `set` function should accept two parameters, `key` and `value`. The value
+ returned from `set` will be the new value of the property.
+
_Note: This is the preferred way to define computed properties when writing third-party
libraries that depend on or use Ember, since there is no guarantee that the user
- will have prototype extensions enabled._
+ will have [prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/) enabled._
- You might use this method if you disabled
- [Prototype Extensions](http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/).
- The alternative syntax might look like this
- (if prototype extensions are enabled, which is the default behavior):
+ The alternative syntax, with prototype extensions, might look like:
```js
fullName() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName')
@@ -3866,11 +4018,11 @@
to return
@return {Object} the cached value
@public
*/
function cacheFor(obj, key) {
- var meta = obj.__ember_meta__;
+ var meta = _emberMetalMeta.peekMeta(obj);
var cache = meta && meta.source === obj && meta.readableCache();
var ret = cache && cache[key];
if (ret === UNDEFINED) {
return undefined;
@@ -3900,11 +4052,11 @@
exports.ComputedProperty = ComputedProperty;
exports.computed = computed;
exports.cacheFor = cacheFor;
});
-enifed('ember-metal/computed_macros', ['exports', 'ember-metal/core', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/computed', 'ember-metal/is_empty', 'ember-metal/is_none', 'ember-metal/alias'], function (exports, _emberMetalCore, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalComputed, _emberMetalIs_empty, _emberMetalIs_none, _emberMetalAlias) {
+enifed('ember-metal/computed_macros', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/computed', 'ember-metal/is_empty', 'ember-metal/is_none', 'ember-metal/alias'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalComputed, _emberMetalIs_empty, _emberMetalIs_none, _emberMetalAlias) {
'use strict';
exports.empty = empty;
exports.notEmpty = notEmpty;
exports.none = none;
@@ -4407,51 +4559,10 @@
return value;
});
exports.or = or;
/**
- A computed property that returns the array of values
- for the provided dependent properties.
-
- Example
-
- ```javascript
- var Hamster = Ember.Object.extend({
- clothes: Ember.computed.collect('hat', 'shirt')
- });
-
- var hamster = Hamster.create();
-
- hamster.get('clothes'); // [null, null]
- hamster.set('hat', 'Camp Hat');
- hamster.set('shirt', 'Camp Shirt');
- hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt']
- ```
-
- @method collect
- @for Ember.computed
- @param {String} dependentKey*
- @return {Ember.ComputedProperty} computed property which maps
- values of all passed in properties to an array.
- @public
- */
- var collect = generateComputedWithProperties(function (properties) {
- var res = _emberMetalCore.default.A();
- for (var key in properties) {
- if (properties.hasOwnProperty(key)) {
- if (_emberMetalIs_none.default(properties[key])) {
- res.push(null);
- } else {
- res.push(properties[key]);
- }
- }
- }
- return res;
- });
-
- exports.collect = collect;
- /**
Creates a new property that is an alias for another property
on an object. Calls to `get` or `set` this property behave as
though they were called on the original property.
```javascript
@@ -4617,11 +4728,11 @@
cross-platform libraries such as jQuery. For more details, see
[Ember-Runtime](http://emberjs.com/api/modules/ember-runtime.html).
@class Ember
@static
- @version 2.2.1
+ @version 2.3.0-beta.1
@public
*/
'use strict';
@@ -4661,15 +4772,15 @@
/**
The semantic version.
@property VERSION
@type String
- @default '2.2.1'
+ @default '2.3.0-beta.1'
@static
@public
*/
- Ember.VERSION = '2.2.1';
+ Ember.VERSION = '2.3.0-beta.1';
/**
The hash of environment variables used to control various configuration
settings. To specify your own or override default settings, add the
desired properties to a global hash named `EmberENV` (or `ENV` for
@@ -5120,11 +5231,11 @@
}
return index;
}
function accumulateListeners(obj, eventName, otherActions) {
- var meta = obj['__ember_meta__'];
+ var meta = _emberMetalMeta.peekMeta(obj);
if (!meta) {
return;
}
var actions = meta.matchingListeners(eventName);
var newActions = [];
@@ -5280,11 +5391,11 @@
@public
*/
function sendEvent(obj, eventName, params, actions) {
if (!actions) {
- var meta = obj['__ember_meta__'];
+ var meta = _emberMetalMeta.peekMeta(obj);
actions = meta && meta.matchingListeners(eventName);
}
if (!actions || actions.length === 0) {
return;
@@ -5332,11 +5443,11 @@
@param obj
@param {String} eventName
*/
function hasListeners(obj, eventName) {
- var meta = obj['__ember_meta__'];
+ var meta = _emberMetalMeta.peekMeta(obj);
if (!meta) {
return false;
}
return meta.matchingListeners(eventName).length > 0;
}
@@ -5349,11 +5460,11 @@
@param {String} eventName
*/
function listenersFor(obj, eventName) {
var ret = [];
- var meta = obj['__ember_meta__'];
+ var meta = _emberMetalMeta.peekMeta(obj);
var actions = meta && meta.matchingListeners(eventName);
if (!actions) {
return ret;
}
@@ -5575,11 +5686,11 @@
ret[propertyNames[i]] = _emberMetalProperty_get.get(obj, propertyNames[i]);
}
return ret;
}
});
-enifed('ember-metal/injected_property', ['exports', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties'], function (exports, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties) {
+enifed('ember-metal/injected_property', ['exports', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties', 'container/owner'], function (exports, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties, _containerOwner) {
'use strict';
/**
Read-only property that returns the result of a container lookup.
@@ -5599,15 +5710,16 @@
AliasedPropertyPrototype.oneWay.call(this);
}
function injectedPropertyGet(keyName) {
var desc = this[keyName];
+ var owner = _containerOwner.getOwner(this);
_emberMetalDebug.assert('InjectedProperties should be defined with the Ember.inject computed property macros.', desc && desc.isDescriptor && desc.type);
- _emberMetalDebug.assert('Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.', this.container);
+ _emberMetalDebug.assert('Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.', owner);
- return this.container.lookup(desc.type + ':' + (desc.name || keyName));
+ return owner.lookup(desc.type + ':' + (desc.name || keyName));
}
InjectedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype);
var InjectedPropertyPrototype = InjectedProperty.prototype;
@@ -5926,10 +6038,12 @@
Ember.isEmpty(''); // true
Ember.isEmpty([]); // true
Ember.isEmpty({}); // false
Ember.isEmpty('Adam Hawkins'); // false
Ember.isEmpty([0,1,2]); // false
+ Ember.isEmpty('\n\t'); // false
+ Ember.isEmpty(' '); // false
```
@method isEmpty
@for Ember
@param {Object} obj Value to test
@@ -6795,10 +6909,12 @@
'no use strict';
// Remove "use strict"; from transpiled module until
// https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed
exports.meta = meta;
+ exports.peekMeta = peekMeta;
+ exports.deleteMeta = deleteMeta;
/**
@module ember-metal
*/
@@ -6833,10 +6949,11 @@
chainWatchers: ownCustomObject,
chains: inheritedCustomObject
};
var memberNames = Object.keys(members);
+ var META_FIELD = '__ember_meta__';
function Meta(obj, parentMeta) {
this._cache = undefined;
this._watching = undefined;
this._mixins = undefined;
@@ -7091,18 +7208,29 @@
value: null
};
exports.META_DESC = META_DESC;
var EMBER_META_PROPERTY = {
- name: '__ember_meta__',
+ name: META_FIELD,
descriptor: META_DESC
};
- // Placeholder for non-writable metas.
- var EMPTY_META = new Meta(null);
+ // choose the one appropriate for given platform
+ var setMeta = function (obj, meta) {
+ // if `null` already, just set it to the new value
+ // otherwise define property first
+ if (obj[META_FIELD] !== null) {
+ if (obj.__defineNonEnumerable) {
+ obj.__defineNonEnumerable(EMBER_META_PROPERTY);
+ } else {
+ Object.defineProperty(obj, META_FIELD, META_DESC);
+ }
+ }
- exports.EMPTY_META = EMPTY_META;
+ obj[META_FIELD] = meta;
+ };
+
/**
Retrieves the meta hash for an object. If `writable` is true ensures the
hash is writable for this object as well.
The meta object contains information about computed property descriptors as
@@ -7118,38 +7246,36 @@
@param {Boolean} [writable=true] Pass `false` if you do not intend to modify
the meta hash, allowing the method to avoid making an unnecessary copy.
@return {Object} the meta hash for an object
*/
- function meta(obj, writable) {
- var ret = obj.__ember_meta__;
- if (writable === false) {
- return ret || EMPTY_META;
- }
+ function meta(obj) {
+ var maybeMeta = peekMeta(obj);
+ var parent = undefined;
- if (ret && ret.source === obj) {
- return ret;
+ // remove this code, in-favor of explicit parent
+ if (maybeMeta) {
+ if (maybeMeta.source === obj) {
+ return maybeMeta;
+ }
+ parent = maybeMeta;
}
- if (!ret) {
- ret = new Meta(obj);
- } else {
- ret = new Meta(obj, ret);
- }
+ var newMeta = new Meta(obj, parent);
+ setMeta(obj, newMeta);
+ return newMeta;
+ }
- // if `null` already, just set it to the new value
- // otherwise define property first
- if (obj.__ember_meta__ !== null) {
- if (obj.__defineNonEnumerable) {
- obj.__defineNonEnumerable(EMBER_META_PROPERTY);
- } else {
- Object.defineProperty(obj, '__ember_meta__', META_DESC);
- }
- }
- obj.__ember_meta__ = ret;
+ function peekMeta(obj) {
+ return obj[META_FIELD];
+ }
- return ret;
+ function deleteMeta(obj) {
+ if (typeof obj[META_FIELD] !== 'object') {
+ return;
+ }
+ obj[META_FIELD] = null;
}
});
enifed('ember-metal/meta_listeners', ['exports'], function (exports) {
/*
When we render a rich template hierarchy, the set of events that
@@ -7330,11 +7456,10 @@
/**
@module ember
@submodule ember-metal
*/
-
exports.mixin = mixin;
exports.default = Mixin;
exports.required = required;
exports.aliasMethod = aliasMethod;
exports.observer = observer;
@@ -7820,10 +7945,14 @@
this.mixins = m;
} else {
this.mixins = undefined;
}
this.ownerConstructor = undefined;
+ this._without = undefined;
+ this[_emberMetalUtils.GUID_KEY] = null;
+ this[_emberMetalUtils.GUID_KEY + '_name'] = null;
+ _emberMetalDebug.debugSeal(this);
}
Mixin._apply = applyMixin;
Mixin.applyPartial = function (obj) {
@@ -7936,11 +8065,11 @@
return false;
}
if (obj instanceof Mixin) {
return _detect(obj, this, {});
}
- var m = obj.__ember_meta__;
+ var m = _emberMetalMeta.peekMeta(obj);
if (!m) {
return false;
}
return !!m.peekMixins(_emberMetalUtils.guidFor(this));
};
@@ -7987,14 +8116,16 @@
}
}
return ret;
};
+ _emberMetalDebug.debugSeal(MixinPrototype);
+
// returns the mixins currently applied to the specified object
// TODO: Make Ember.mixin
Mixin.mixins = function (obj) {
- var m = obj['__ember_meta__'];
+ var m = _emberMetalMeta.peekMeta(obj);
var ret = [];
if (!m) {
return ret;
}
@@ -8081,11 +8212,11 @@
@method observer
@for Ember
@param {String} propertyNames*
@param {Function} func
@return func
- @private
+ @public
*/
function observer() {
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
@@ -8596,14 +8727,14 @@
}
return this;
}
});
-enifed('ember-metal/property_events', ['exports', 'ember-metal/utils', 'ember-metal/events', 'ember-metal/observer_set'], function (exports, _emberMetalUtils, _emberMetalEvents, _emberMetalObserver_set) {
+enifed('ember-metal/property_events', ['exports', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/observer_set', 'ember-metal/symbol'], function (exports, _emberMetalUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalObserver_set, _emberMetalSymbol) {
'use strict';
- var PROPERTY_DID_CHANGE = _emberMetalUtils.symbol('PROPERTY_DID_CHANGE');
+ var PROPERTY_DID_CHANGE = _emberMetalSymbol.default('PROPERTY_DID_CHANGE');
exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE;
var beforeObserverSet = new _emberMetalObserver_set.default();
var observerSet = new _emberMetalObserver_set.default();
var deferred = 0;
@@ -8627,11 +8758,11 @@
@param {String} keyName The property key (or path) that will change.
@return {void}
@private
*/
function propertyWillChange(obj, keyName) {
- var m = obj['__ember_meta__'];
+ var m = _emberMetalMeta.peekMeta(obj);
var watching = m && m.peekWatching(keyName) > 0 || keyName === 'length';
var proto = m && m.proto;
var possibleDesc = obj[keyName];
var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
@@ -8667,11 +8798,11 @@
@param {String} keyName The property key (or path) that will change.
@return {void}
@private
*/
function propertyDidChange(obj, keyName) {
- var m = obj['__ember_meta__'];
+ var m = _emberMetalMeta.peekMeta(obj);
var watching = m && m.peekWatching(keyName) > 0 || keyName === 'length';
var proto = m && m.proto;
var possibleDesc = obj[keyName];
var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
@@ -8879,11 +9010,11 @@
exports.overrideChains = overrideChains;
exports.beginPropertyChanges = beginPropertyChanges;
exports.endPropertyChanges = endPropertyChanges;
exports.changeProperties = changeProperties;
});
-enifed('ember-metal/property_get', ['exports', 'ember-metal/core', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/error', 'ember-metal/path_cache'], function (exports, _emberMetalCore, _emberMetalDebug, _emberMetalFeatures, _emberMetalError, _emberMetalPath_cache) {
+enifed('ember-metal/property_get', ['exports', 'ember-metal/core', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalCore, _emberMetalDebug, _emberMetalFeatures, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) {
/**
@module ember-metal
*/
'use strict';
@@ -8937,13 +9068,13 @@
// Helpers that operate with 'this' within an #each
if (keyName === '') {
return obj;
}
- var meta = obj['__ember_meta__'];
- var possibleDesc = obj[keyName];
- var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
+ var meta = _emberMetalMeta.peekMeta(obj);
+ var value = obj[keyName];
+ var desc = value !== null && typeof value === 'object' && value.isDescriptor ? value : undefined;
var ret;
if (desc === undefined && _emberMetalPath_cache.isPath(keyName)) {
return _getPath(obj, keyName);
}
@@ -8953,14 +9084,14 @@
} else {
if (_emberMetalFeatures.default('mandatory-setter')) {
if (meta && meta.peekWatching(keyName) > 0) {
ret = meta.peekValues(keyName);
} else {
- ret = obj[keyName];
+ ret = value;
}
} else {
- ret = obj[keyName];
+ ret = value;
}
if (ret === undefined && 'object' === typeof obj && !(keyName in obj) && 'function' === typeof obj.unknownProperty) {
return obj.unknownProperty(keyName);
}
@@ -9040,10 +9171,27 @@
}
}
return root;
}
+ /**
+ Retrieves the value of a property from an Object, or a default value in the
+ case that the property returns `undefined`.
+
+ ```javascript
+ Ember.getWithDefault(person, 'lastName', 'Doe');
+ ```
+
+ @method getWithDefault
+ @for Ember
+ @param {Object} obj The object to retrieve from.
+ @param {String} keyName The name of the property to retrieve
+ @param {Object} defaultValue The value to return if the property value is undefined
+ @return {Object} The property value or the defaultValue.
+ @public
+ */
+
function getWithDefault(root, key, defaultValue) {
var value = get(root, key);
if (value === undefined) {
return defaultValue;
@@ -9051,11 +9199,11 @@
return value;
}
exports.default = get;
});
-enifed('ember-metal/property_set', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/error', 'ember-metal/path_cache'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalProperties, _emberMetalError, _emberMetalPath_cache) {
+enifed('ember-metal/property_set', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalProperties, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) {
'use strict';
exports.set = set;
exports.trySet = trySet;
@@ -9080,11 +9228,11 @@
_emberMetalDebug.assert('The key provided to set must be a string, you passed ' + keyName, typeof keyName === 'string');
_emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName));
var meta, possibleDesc, desc;
if (obj) {
- meta = obj['__ember_meta__'];
+ meta = _emberMetalMeta.peekMeta(obj);
possibleDesc = obj[keyName];
desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
}
var isUnknown, currentValue;
@@ -10054,11 +10202,15 @@
exports.default = Dependency;
});
enifed('ember-metal/streams/key-stream', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/observer', 'ember-metal/streams/stream', 'ember-metal/streams/utils'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalObserver, _emberMetalStreamsStream, _emberMetalStreamsUtils) {
'use strict';
- var KeyStream = _emberMetalStreamsStream.default.extend({
+ function labelFor(source, key) {
+ return source.label ? source.label + '.' + key : key;
+ }
+
+ exports.default = _emberMetalStreamsStream.default.extend({
init: function (source, key) {
_emberMetalDebug.assert('KeyStream error: source must be a stream', _emberMetalStreamsUtils.isStream(source)); // TODO: This isn't necessary.
_emberMetalDebug.assert('KeyStream error: key must be a non-empty string', typeof key === 'string' && key.length > 0);
_emberMetalDebug.assert('KeyStream error: key must not have a \'.\'', key.indexOf('.') === -1);
@@ -10071,13 +10223,21 @@
this.label = label;
},
compute: function () {
var object = this.sourceDep.getValue();
- if (object) {
+ var type = typeof object;
+
+ if (!object || type === 'boolean') {
+ return;
+ }
+
+ if (type === 'object') {
return _emberMetalProperty_get.get(object, this.key);
}
+
+ return object[this.key];
},
setValue: function (value) {
var object = this.sourceDep.getValue();
if (object) {
@@ -10118,16 +10278,10 @@
deactivate: function () {
this._super$deactivate();
this._clearObservedObject();
}
});
-
- function labelFor(source, key) {
- return source.label ? source.label + '.' + key : key;
- }
-
- exports.default = KeyStream;
});
enifed('ember-metal/streams/proxy-stream', ['exports', 'ember-runtime/system/object', 'ember-metal/streams/stream'], function (exports, _emberRuntimeSystemObject, _emberMetalStreamsStream) {
'use strict';
var ProxyStream = _emberMetalStreamsStream.default.extend({
@@ -10157,11 +10311,11 @@
ProxyStream.extend = _emberMetalStreamsStream.default.extend;
exports.default = ProxyStream;
});
-enifed('ember-metal/streams/stream', ['exports', 'ember-metal/core', 'ember-metal/assign', 'ember-metal/debug', 'ember-metal/path_cache', 'ember-metal/observer', 'ember-metal/streams/utils', 'ember-metal/empty_object', 'ember-metal/streams/subscriber', 'ember-metal/streams/dependency', 'ember-metal/utils'], function (exports, _emberMetalCore, _emberMetalAssign, _emberMetalDebug, _emberMetalPath_cache, _emberMetalObserver, _emberMetalStreamsUtils, _emberMetalEmpty_object, _emberMetalStreamsSubscriber, _emberMetalStreamsDependency, _emberMetalUtils) {
+enifed('ember-metal/streams/stream', ['exports', 'ember-metal/assign', 'ember-metal/debug', 'ember-metal/path_cache', 'ember-metal/observer', 'ember-metal/streams/utils', 'ember-metal/empty_object', 'ember-metal/streams/subscriber', 'ember-metal/streams/dependency', 'ember-metal/utils', 'require'], function (exports, _emberMetalAssign, _emberMetalDebug, _emberMetalPath_cache, _emberMetalObserver, _emberMetalStreamsUtils, _emberMetalEmpty_object, _emberMetalStreamsSubscriber, _emberMetalStreamsDependency, _emberMetalUtils, _require) {
'use strict';
exports.wrap = wrap;
/**
@@ -10199,11 +10353,11 @@
this.__ember_meta__ = null;
this[_emberMetalUtils.GUID_KEY] = null;
},
_makeChildStream: function (key) {
- KeyStream = KeyStream || _emberMetalCore.default.__loader.require('ember-metal/streams/key-stream').default;
+ KeyStream = KeyStream || _require.default('ember-metal/streams/key-stream').default;
return new KeyStream(this, key);
},
removeChild: function (key) {
delete this.children[key];
@@ -10339,11 +10493,11 @@
revalidate: function (value) {
if (value !== this.observedProxy) {
this._clearObservedProxy();
- ProxyMixin = ProxyMixin || _emberMetalCore.default.__loader.require('ember-runtime/mixins/-proxy').default;
+ ProxyMixin = ProxyMixin || _require.default('ember-runtime/mixins/-proxy').default;
if (ProxyMixin.detect(value)) {
_emberMetalObserver.addObserver(value, 'content', this, this.notify);
this.observedProxy = value;
}
@@ -10934,12 +11088,22 @@
if (object && object.isStream) {
object.setValue(value);
}
}
});
-enifed("ember-metal/symbol", ["exports"], function (exports) {
- "use strict";
+enifed('ember-metal/symbol', ['exports', 'ember-metal/utils'], function (exports, _emberMetalUtils) {
+ 'use strict';
+
+ exports.default = symbol;
+
+ function symbol(debugName) {
+ // TODO: Investigate using platform symbols, but we do not
+ // want to require non-enumerability for this API, which
+ // would introduce a large cost.
+
+ return _emberMetalUtils.intern(debugName + ' [id=' + _emberMetalUtils.GUID_KEY + Math.floor(Math.random() * new Date()) + ']');
+ }
});
enifed('ember-metal/utils', ['exports'], function (exports) {
'no use strict';
// Remove "use strict"; from transpiled module until
// https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed
@@ -10954,11 +11118,11 @@
@private
@return {Number} the uuid
*/
exports.uuid = uuid;
- exports.symbol = symbol;
+ exports.intern = intern;
exports.generateGuid = generateGuid;
exports.guidFor = guidFor;
exports.wrap = wrap;
exports.tryInvoke = tryInvoke;
exports.makeArray = makeArray;
@@ -11031,10 +11195,11 @@
Known Trickā¢
@private
@return {String} interned version of the provided string
*/
+
function intern(str) {
var obj = {};
obj[str] = 1;
for (var key in obj) {
if (key === str) {
@@ -11042,18 +11207,10 @@
}
}
return str;
}
- function symbol(debugName) {
- // TODO: Investigate using platform symbols, but we do not
- // want to require non-enumerability for this API, which
- // would introduce a large cost.
-
- return intern(debugName + ' [id=' + GUID_KEY + Math.floor(Math.random() * new Date()) + ']');
- }
-
/**
A unique key used to assign guids and other private metadata to objects.
If you inspect an object in your browser debugger you will often see these.
They can be safely ignored.
@@ -11512,10 +11669,13 @@
'use strict';
exports.watchKey = watchKey;
exports.unwatchKey = unwatchKey;
+ var handleMandatorySetter = undefined,
+ lookupDescriptor = undefined;
+
function watchKey(obj, keyName, meta) {
// can't watch length on Array - it is special...
if (keyName === 'length' && Array.isArray(obj)) {
return;
}
@@ -11543,12 +11703,27 @@
m.writeWatching(keyName, (m.peekWatching(keyName) || 0) + 1);
}
}
if (_emberMetalFeatures.default('mandatory-setter')) {
- var handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) {
- var descriptor = Object.getOwnPropertyDescriptor && Object.getOwnPropertyDescriptor(obj, keyName);
+ lookupDescriptor = function lookupDescriptor(obj, keyName) {
+ var current = obj;
+ while (current) {
+ var descriptor = Object.getOwnPropertyDescriptor(current, keyName);
+
+ if (descriptor) {
+ return descriptor;
+ }
+
+ current = Object.getPrototypeOf(current);
+ }
+
+ return null;
+ };
+
+ handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) {
+ var descriptor = lookupDescriptor(obj, keyName);
var configurable = descriptor ? descriptor.configurable : true;
var isWritable = descriptor ? descriptor.writable : true;
var hasValue = descriptor ? 'value' in descriptor : true;
var possibleDesc = descriptor && descriptor.value;
var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor;
@@ -11654,11 +11829,11 @@
} else if (counter > 1) {
m.writeWatching(keyPath, counter - 1);
}
}
});
-enifed('ember-metal/watching', ['exports', 'ember-metal/chains', 'ember-metal/watch_key', 'ember-metal/watch_path', 'ember-metal/path_cache'], function (exports, _emberMetalChains, _emberMetalWatch_key, _emberMetalWatch_path, _emberMetalPath_cache) {
+enifed('ember-metal/watching', ['exports', 'ember-metal/chains', 'ember-metal/watch_key', 'ember-metal/watch_path', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberMetalChains, _emberMetalWatch_key, _emberMetalWatch_path, _emberMetalPath_cache, _emberMetalMeta) {
/**
@module ember-metal
*/
'use strict';
@@ -11694,11 +11869,11 @@
}
exports.watch = watch;
function isWatching(obj, key) {
- var meta = obj['__ember_meta__'];
+ var meta = _emberMetalMeta.peekMeta(obj);
return (meta && meta.peekWatching(key)) > 0;
}
watch.flushPending = _emberMetalChains.flushPendingChains;
@@ -11727,15 +11902,15 @@
@return {void}
@private
*/
function destroy(obj) {
- var meta = obj['__ember_meta__'];
+ var meta = _emberMetalMeta.peekMeta(obj);
var node, nodes, key, nodeObject;
if (meta) {
- obj['__ember_meta__'] = null;
+ _emberMetalMeta.deleteMeta(obj);
// remove chainWatchers to remove circular references that would prevent GC
node = meta.readableChains();
if (node) {
NODE_STACK.push(node);
// process tree
@@ -11815,13 +11990,13 @@
};
_emberMetalCore.default.Error = _emberMetalError.default;
_emberMetalCore.default.guidFor = _emberMetalUtils.guidFor;
_emberMetalCore.default.META_DESC = _emberMetalMeta.META_DESC;
- _emberMetalCore.default.EMPTY_META = _emberMetalMeta.EMPTY_META;
_emberMetalCore.default.meta = _emberMetalMeta.meta;
_emberMetalCore.default.inspect = _emberMetalUtils.inspect;
+
_emberMetalCore.default.tryCatchFinally = _emberMetalUtils.deprecatedTryCatchFinally;
_emberMetalCore.default.makeArray = _emberMetalUtils.makeArray;
_emberMetalCore.default.canInvoke = _emberMetalUtils.canInvoke;
_emberMetalCore.default.tryInvoke = _emberMetalUtils.tryInvoke;
_emberMetalCore.default.wrap = _emberMetalUtils.wrap;
@@ -12095,11 +12270,11 @@
default:
return 0;
}
}
});
-enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/error', 'ember-metal/computed', 'ember-metal/observer', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalError, _emberMetalComputed, _emberMetalObserver, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array) {
+enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/error', 'ember-metal/computed', 'ember-metal/observer', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array', 'ember-metal/is_none', 'ember-metal/get_properties'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalError, _emberMetalComputed, _emberMetalObserver, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array, _emberMetalIs_none, _emberMetalGet_properties) {
/**
@module ember
@submodule ember-runtime
*/
@@ -12113,10 +12288,11 @@
exports.filter = filter;
exports.filterBy = filterBy;
exports.uniq = uniq;
exports.intersect = intersect;
exports.setDiff = setDiff;
+ exports.collect = collect;
exports.sort = sort;
function reduceMacro(dependentKey, callback, initialValue) {
return _emberMetalComputed.computed(dependentKey + '.[]', function () {
var _this = this;
@@ -12618,10 +12794,58 @@
});
}).readOnly();
}
/**
+ A computed property that returns the array of values
+ for the provided dependent properties.
+
+ Example
+
+ ```javascript
+ var Hamster = Ember.Object.extend({
+ clothes: Ember.computed.collect('hat', 'shirt')
+ });
+
+ var hamster = Hamster.create();
+
+ hamster.get('clothes'); // [null, null]
+ hamster.set('hat', 'Camp Hat');
+ hamster.set('shirt', 'Camp Shirt');
+ hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt']
+ ```
+
+ @method collect
+ @for Ember.computed
+ @param {String} dependentKey*
+ @return {Ember.ComputedProperty} computed property which maps
+ values of all passed in properties to an array.
+ @public
+ */
+
+ function collect() {
+ for (var _len3 = arguments.length, dependentKeys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
+ dependentKeys[_key3] = arguments[_key3];
+ }
+
+ return multiArrayMacro(dependentKeys, function () {
+ var properties = _emberMetalGet_properties.default(this, dependentKeys);
+ var res = _emberRuntimeSystemNative_array.A();
+ for (var key in properties) {
+ if (properties.hasOwnProperty(key)) {
+ if (_emberMetalIs_none.default(properties[key])) {
+ res.push(null);
+ } else {
+ res.push(properties[key]);
+ }
+ }
+ }
+ return res;
+ });
+ }
+
+ /**
A computed property which returns a new array with all the
properties from the first dependent array sorted based on a property
or sort function.
The callback method you provide should have the following signature:
@@ -14221,17 +14445,19 @@
@private
*/
compare: null
});
});
-enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal/run_loop', 'ember-metal/mixin'], function (exports, _emberMetalRun_loop, _emberMetalMixin) {
+enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/mixin'], function (exports, _emberMetalRun_loop, _emberMetalDebug, _emberMetalMixin) {
/**
@module ember
@submodule ember-runtime
*/
'use strict';
+ exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations;
+
/**
ContainerProxyMixin is used to provide public access to specific
container functionality.
@class ContainerProxyMixin
@@ -14304,10 +14530,35 @@
var _container__;
return (_container__ = this.__container__)[name].apply(_container__, arguments);
};
}
+
+ function buildFakeContainerWithDeprecations(container) {
+ var fakeContainer = {};
+ var propertyMappings = {
+ lookup: 'lookup',
+ lookupFactory: '_lookupFactory'
+ };
+
+ for (var containerProperty in propertyMappings) {
+ fakeContainer[containerProperty] = buildFakeContainerFunction(container, containerProperty, propertyMappings[containerProperty]);
+ }
+
+ return fakeContainer;
+ }
+
+ function buildFakeContainerFunction(container, containerProperty, ownerProperty) {
+ return function () {
+ _emberMetalDebug.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper to access the owner of this object and then call `' + ownerProperty + '` instead.', false, {
+ id: 'ember-application.injected-container',
+ until: '3.0.0',
+ url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access'
+ });
+ return container[containerProperty].apply(container, arguments);
+ };
+ }
});
enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal/mixin', 'ember-metal/alias', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetalMixin, _emberMetalAlias, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) {
'use strict';
/**
@@ -14336,12 +14587,10 @@
@default null
@public
*/
target: null,
- container: null,
-
parentController: null,
store: null,
/**
@@ -14459,11 +14708,11 @@
throw new _emberMetalError.default(this + ' does not support freezing');
}
}
});
});
-enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-metal/core', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/mixin', 'ember-metal/computed', 'ember-metal/property_events', 'ember-metal/events', 'ember-runtime/compare'], function (exports, _emberMetalCore, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalMixin, _emberMetalComputed, _emberMetalProperty_events, _emberMetalEvents, _emberRuntimeCompare) {
+enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/mixin', 'ember-metal/computed', 'ember-metal/property_events', 'ember-metal/events', 'ember-runtime/compare', 'require'], function (exports, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalMixin, _emberMetalComputed, _emberMetalProperty_events, _emberMetalEvents, _emberRuntimeCompare, _require) {
/**
@module ember
@submodule ember-runtime
*/
@@ -14471,10 +14720,16 @@
// HELPERS
//
'use strict';
+ var _emberA = undefined;
+
+ function emberA() {
+ return (_emberA || (_emberA = _require.default('ember-runtime/system/native_array').A))();
+ }
+
var contexts = [];
function popCtx() {
return contexts.length === 0 ? {} : contexts.pop();
}
@@ -14748,11 +15003,11 @@
@param {Object} [target] The target object to use
@return {Array} The mapped array.
@public
*/
map: function (callback, target) {
- var ret = _emberMetalCore.default.A();
+ var ret = emberA();
this.forEach(function (x, idx, i) {
ret[idx] = callback.call(target, x, idx, i);
});
@@ -14795,11 +15050,11 @@
@param {Object} [target] The target object to use
@return {Array} A filtered array.
@public
*/
filter: function (callback, target) {
- var ret = _emberMetalCore.default.A();
+ var ret = emberA();
this.forEach(function (x, idx, i) {
if (callback.call(target, x, idx, i)) {
ret.push(x);
}
@@ -15106,11 +15361,11 @@
invoke: function (methodName) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
- var ret = _emberMetalCore.default.A();
+ var ret = emberA();
this.forEach(function (x, idx) {
var method = x && x[methodName];
if ('function' === typeof method) {
@@ -15127,11 +15382,11 @@
@method toArray
@return {Array} the enumerable as an array.
@public
*/
toArray: function () {
- var ret = _emberMetalCore.default.A();
+ var ret = emberA();
this.forEach(function (o, idx) {
ret[idx] = o;
});
@@ -15170,11 +15425,11 @@
without: function (value) {
if (!this.contains(value)) {
return this; // nothing to do
}
- var ret = _emberMetalCore.default.A();
+ var ret = emberA();
this.forEach(function (k) {
if (k !== value) {
ret[ret.length] = k;
}
@@ -15194,11 +15449,11 @@
@method uniq
@return {Ember.Enumerable}
@public
*/
uniq: function () {
- var ret = _emberMetalCore.default.A();
+ var ret = emberA();
this.forEach(function (k) {
if (ret.indexOf(k) < 0) {
ret.push(k);
}
@@ -17177,10 +17432,33 @@
});
exports.default = TargetActionSupport;
});
// Ember.lookup
+enifed("ember-runtime/string_registry", ["exports"], function (exports) {
+ // STATE within a module is frowned apon, this exists
+ // to support Ember.STRINGS but shield ember internals from this legacy global
+ // API.
+ "use strict";
+
+ exports.setStrings = setStrings;
+ exports.getStrings = getStrings;
+ exports.get = get;
+ var STRINGS = {};
+
+ function setStrings(strings) {
+ STRINGS = strings;
+ }
+
+ function getStrings() {
+ return STRINGS;
+ }
+
+ function get(name) {
+ return STRINGS[name];
+ }
+});
enifed('ember-runtime/system/application', ['exports', 'ember-runtime/system/namespace'], function (exports, _emberRuntimeSystemNamespace) {
'use strict';
exports.default = _emberRuntimeSystemNamespace.default.extend();
});
@@ -17543,20 +17821,22 @@
}
});
exports.default = ArrayProxy;
});
-enifed('ember-runtime/system/container', ['exports', 'ember-metal/property_set', 'container/registry', 'container/container'], function (exports, _emberMetalProperty_set, _containerRegistry, _containerContainer) {
+enifed('ember-runtime/system/container', ['exports', 'ember-metal/property_set', 'container/registry', 'container/container', 'container/owner'], function (exports, _emberMetalProperty_set, _containerRegistry, _containerContainer, _containerOwner) {
'use strict';
_containerRegistry.default.set = _emberMetalProperty_set.set;
_containerContainer.default.set = _emberMetalProperty_set.set;
exports.Registry = _containerRegistry.default;
exports.Container = _containerContainer.default;
+ exports.getOwner = _containerOwner.getOwner;
+ exports.setOwner = _containerOwner.setOwner;
});
-enifed('ember-runtime/system/core_object', ['exports', 'ember-metal', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/assign', 'ember-metal/property_get', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/chains', 'ember-metal/events', 'ember-metal/mixin', 'ember-metal/error', 'ember-runtime/mixins/action_handler', 'ember-metal/properties', 'ember-metal/binding', 'ember-metal/computed', 'ember-metal/injected_property', 'ember-metal/run_loop', 'ember-metal/watching', 'ember-metal/core', 'ember-runtime/inject'], function (exports, _emberMetal, _emberMetalDebug, _emberMetalFeatures, _emberMetalAssign, _emberMetalProperty_get, _emberMetalUtils, _emberMetalMeta, _emberMetalChains, _emberMetalEvents, _emberMetalMixin, _emberMetalError, _emberRuntimeMixinsAction_handler, _emberMetalProperties, _emberMetalBinding, _emberMetalComputed, _emberMetalInjected_property, _emberMetalRun_loop, _emberMetalWatching, _emberMetalCore, _emberRuntimeInject) {
+enifed('ember-runtime/system/core_object', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/assign', 'ember-metal/property_get', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/chains', 'ember-metal/events', 'ember-metal/mixin', 'ember-metal/error', 'ember-runtime/mixins/action_handler', 'ember-metal/properties', 'ember-metal/binding', 'ember-metal/computed', 'ember-metal/injected_property', 'ember-metal/run_loop', 'ember-metal/watching', 'ember-metal/core', 'ember-runtime/inject', 'ember-metal/symbol'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalAssign, _emberMetalProperty_get, _emberMetalUtils, _emberMetalMeta, _emberMetalChains, _emberMetalEvents, _emberMetalMixin, _emberMetalError, _emberRuntimeMixinsAction_handler, _emberMetalProperties, _emberMetalBinding, _emberMetalComputed, _emberMetalInjected_property, _emberMetalRun_loop, _emberMetalWatching, _emberMetalCore, _emberRuntimeInject, _emberMetalSymbol) {
'no use strict';
// Remove "use strict"; from transpiled module until
// https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed
/**
@@ -17567,11 +17847,11 @@
// using ember-metal/lib/main here to ensure that ember-debug is setup
// if present
var _Mixin$create;
- var POST_INIT = _emberMetalUtils.symbol('POST_INIT');
+ var POST_INIT = _emberMetalSymbol.default('POST_INIT');
exports.POST_INIT = POST_INIT;
var schedule = _emberMetalRun_loop.default.schedule;
var applyMixin = _emberMetalMixin.Mixin._apply;
var finishPartial = _emberMetalMixin.Mixin.finishPartial;
var reopen = _emberMetalMixin.Mixin.prototype.reopen;
@@ -18177,12 +18457,12 @@
CoreObject.reopen({
didDefineProperty: function (proto, key, value) {
if (hasCachedComputedProperties === false) {
return;
}
- if (value instanceof _emberMetal.default.ComputedProperty) {
- var cache = _emberMetal.default.meta(this.constructor).readableCache();
+ if (value instanceof _emberMetalComputed.ComputedProperty) {
+ var cache = _emberMetalMeta.meta(this.constructor).readableCache();
if (cache && cache._computedProperties !== undefined) {
cache._computedProperties = undefined;
}
}
@@ -18679,14 +18959,13 @@
// the key, so processing `Ember.View` will make the Array
// `['Ember', 'View']`.
paths[idx] = key;
// If we have found an unprocessed class
- if (obj && obj.toString === classToString) {
+ if (obj && obj.toString === classToString && !obj[NAME_KEY]) {
// Replace the class' `toString` with the dot-separated path
// and set its `NAME_KEY`
- obj.toString = makeToString(paths.join('.'));
obj[NAME_KEY] = paths.join('.');
// Support nested namespaces
} else if (obj && obj.isNamespace) {
// Skip aliased namespaces
@@ -18941,48 +19220,25 @@
@method A
@for Ember
@return {Ember.NativeArray}
@public
*/
- var A = function (arr) {
- if (arr === undefined) {
- arr = [];
- }
- return _emberRuntimeMixinsArray.default.detect(arr) ? arr : NativeArray.apply(arr);
- };
+ var A;
- /**
- Activates the mixin on the Array.prototype if not already applied. Calling
- this method more than once is safe. This will be called when ember is loaded
- unless you have `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Array`
- set to `false`.
-
- Example
-
- ```js
- if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Array) {
- Ember.NativeArray.activate();
- }
- ```
-
- @method activate
- @for Ember.NativeArray
- @static
- @return {void}
- @private
- */
- NativeArray.activate = function () {
+ if (_emberMetalCore.default.EXTEND_PROTOTYPES === true || _emberMetalCore.default.EXTEND_PROTOTYPES.Array) {
NativeArray.apply(Array.prototype);
-
exports. // ES6TODO: Setting A onto the object returned by ember-metal/core to avoid circles
A = A = function (arr) {
return arr || [];
};
- };
-
- if (_emberMetalCore.default.EXTEND_PROTOTYPES === true || _emberMetalCore.default.EXTEND_PROTOTYPES.Array) {
- NativeArray.activate();
+ } else {
+ exports.A = A = function (arr) {
+ if (arr === undefined) {
+ arr = [];
+ }
+ return _emberRuntimeMixinsArray.default.detect(arr) ? arr : NativeArray.apply(arr);
+ };
}
_emberMetalCore.default.A = A;exports.A = A;
exports.NativeArray = NativeArray;
exports.default = NativeArray;
@@ -19135,11 +19391,11 @@
isServiceFactory: true
});
exports.default = Service;
});
-enifed('ember-runtime/system/string', ['exports', 'ember-metal/core', 'ember-metal/debug', 'ember-metal/utils', 'ember-runtime/utils', 'ember-metal/cache'], function (exports, _emberMetalCore, _emberMetalDebug, _emberMetalUtils, _emberRuntimeUtils, _emberMetalCache) {
+enifed('ember-runtime/system/string', ['exports', 'ember-metal/debug', 'ember-metal/utils', 'ember-runtime/utils', 'ember-runtime/string_registry', 'ember-metal/cache'], function (exports, _emberMetalDebug, _emberMetalUtils, _emberRuntimeUtils, _emberRuntimeString_registry, _emberMetalCache) {
/**
@module ember
@submodule ember-runtime
*/
'use strict';
@@ -19230,11 +19486,11 @@
function loc(str, formats) {
if (!_emberRuntimeUtils.isArray(formats) || arguments.length > 2) {
formats = Array.prototype.slice.call(arguments, 1);
}
- str = _emberMetalCore.default.STRINGS[str] || str;
+ str = _emberRuntimeString_registry.get(str) || str;
return _fmt(str, formats);
}
function w(str) {
return str.split(/\s+/);
@@ -19263,22 +19519,10 @@
function capitalize(str) {
return CAPITALIZE_CACHE.get(str);
}
/**
- Defines the hash of localized strings for the current language. Used by
- the `Ember.String.loc()` helper. To localize, add string values to this
- hash.
-
- @property STRINGS
- @for Ember
- @type Object
- @private
- */
- _emberMetalCore.default.STRINGS = {};
-
- /**
Defines string helper methods including string formatting and localization.
Unless `Ember.EXTEND_PROTOTYPES.String` is `false` these methods will also be
added to the `String.prototype` as well.
@class String
@@ -19455,11 +19699,10 @@
exports.camelize = camelize;
exports.classify = classify;
exports.underscore = underscore;
exports.capitalize = capitalize;
});
-// Ember.STRINGS
enifed('ember-runtime/utils', ['exports', 'ember-runtime/mixins/array', 'ember-runtime/system/object'], function (exports, _emberRuntimeMixinsArray, _emberRuntimeSystemObject) {
'use strict';
exports.isArray = isArray;
exports.typeOf = typeOf;
@@ -19604,11 +19847,11 @@
}
return ret;
}
});
-enifed('ember-runtime', ['exports', 'ember-metal', 'ember-runtime/is-equal', 'ember-runtime/compare', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/system/namespace', 'ember-runtime/system/object', 'ember-runtime/system/container', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/system/string', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/utils'], function (exports, _emberMetal, _emberRuntimeIsEqual, _emberRuntimeCompare, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeSystemNamespace, _emberRuntimeSystemObject, _emberRuntimeSystemContainer, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeSystemString, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeMixinsObservable, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeUtils) {
+enifed('ember-runtime', ['exports', 'ember-metal', 'ember-runtime/is-equal', 'ember-runtime/compare', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/system/namespace', 'ember-runtime/system/object', 'ember-runtime/system/container', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/system/string', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/utils', 'ember-metal/features', 'ember-runtime/mixins/registry_proxy', 'ember-runtime/mixins/container_proxy', 'ember-runtime/string_registry'], function (exports, _emberMetal, _emberRuntimeIsEqual, _emberRuntimeCompare, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeSystemNamespace, _emberRuntimeSystemObject, _emberRuntimeSystemContainer, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeSystemString, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeMixinsObservable, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeUtils, _emberMetalFeatures, _emberRuntimeMixinsRegistry_proxy, _emberRuntimeMixinsContainer_proxy, _emberRuntimeString_registry) {
/**
@module ember
@submodule ember-runtime
*/
@@ -19663,10 +19906,19 @@
_emberMetal.default.String = _emberRuntimeSystemString.default;
_emberMetal.default.Object = _emberRuntimeSystemObject.default;
_emberMetal.default.Container = _emberRuntimeSystemContainer.Container;
_emberMetal.default.Registry = _emberRuntimeSystemContainer.Registry;
+
+ if (_emberMetalFeatures.default('ember-container-inject-owner')) {
+ _emberMetal.default.getOwner = _emberRuntimeSystemContainer.getOwner;
+ _emberMetal.default.setOwner = _emberRuntimeSystemContainer.setOwner;
+
+ _emberMetal.default._RegistryProxyMixin = _emberRuntimeMixinsRegistry_proxy.default;
+ _emberMetal.default._ContainerProxyMixin = _emberRuntimeMixinsContainer_proxy.default;
+ }
+
_emberMetal.default.Namespace = _emberRuntimeSystemNamespace.default;
_emberMetal.default.Enumerable = _emberRuntimeMixinsEnumerable.default;
_emberMetal.default.ArrayProxy = _emberRuntimeSystemArray_proxy.default;
_emberMetal.default.ObjectProxy = _emberRuntimeSystemObject_proxy.default;
_emberMetal.default.ActionHandler = _emberRuntimeMixinsAction_handler.default;
@@ -19684,9 +19936,25 @@
_emberMetal.default._ProxyMixin = _emberRuntimeMixinsProxy.default;
_emberMetal.default.RSVP = _emberRuntimeExtRsvp.default;
// END EXPORTS
+
+ /**
+ Defines the hash of localized strings for the current language. Used by
+ the `Ember.String.loc()` helper. To localize, add string values to this
+ hash.
+
+ @property STRINGS
+ @for Ember
+ @type Object
+ @private
+ */
+ Object.defineProperty(_emberMetal.default, 'STRINGS', {
+ configurable: false,
+ get: _emberRuntimeString_registry.getStrings,
+ set: _emberRuntimeString_registry.setStrings
+ });
exports.default = _emberMetal.default;
});
// just for side effect of extending Ember.RSVP
// just for side effect of extending String.prototype
\ No newline at end of file