dist/ember.js in ember-source-2.13.0.beta.2 vs dist/ember.js in ember-source-2.13.0

- old
+ new

@@ -4,11 +4,11 @@ * @copyright Copyright 2011-2017 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.13.0-beta.2 + * @version 2.13.0 */ var enifed, requireModule, Ember; var mainContext = this; // Used in ember-environment/lib/global.js @@ -3487,10 +3487,12 @@ var injections = injectionsFor(container, fullName); var factoryInjections = factoryInjectionsFor(container, fullName); var cacheable = !areInjectionsDynamic(injections) && !areInjectionsDynamic(factoryInjections); factoryInjections[_emberUtils.NAME_KEY] = registry.makeToString(factory, fullName); + injections._debugContainerKey = fullName; + _emberUtils.setOwner(injections, container.owner); var injectedFactory = factory.extend(injections); // TODO - remove all `container` injections when Ember reaches v3.0.0 injectDeprecatedContainer(injectedFactory.prototype, container); @@ -3512,14 +3514,11 @@ var registry = container.registry; var splitName = fullName.split(':'); var type = splitName[0]; var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName)); - injections._debugContainerKey = fullName; - _emberUtils.setOwner(injections, container.owner); - return injections; } function instantiate(factory, props, container, fullName) { var lazyInjections = undefined, @@ -3558,10 +3557,11 @@ } else { // assume the factory was extendable // to create time injections // TODO: support new'ing for instantiation and merge injections for pure JS Functions var injections = injectionsFor(container, fullName); + injections._debugContainerKey = fullName; // Ensure that a container is available to an object during instantiation. // TODO - remove when Ember reaches v3.0.0 // This "fake" container will be replaced after instantiation with a // property that raises deprecations every time it is accessed. @@ -3587,31 +3587,33 @@ factoryInjections._debugContainerKey = fullName; return factoryInjections; } + var INJECTED_DEPRECATED_CONTAINER_DESC = { + configurable: true, + enumerable: false, + get: function () { + _emberDebug.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: '2.13.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); + return this[CONTAINER_OVERRIDE] || _emberUtils.getOwner(this).__container__; + }, + + set: function (value) { + _emberDebug.deprecate('Providing the `container` property to ' + this + ' is deprecated. Please use `Ember.setOwner` or `owner.ownerInjection()` instead to provide an owner to the instance being created.', false, { id: 'ember-application.injected-container', until: '2.13.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); + + this[CONTAINER_OVERRIDE] = value; + + return value; + } + }; + // TODO - remove when Ember reaches v3.0.0 function injectDeprecatedContainer(object, container) { if ('container' in object) { return; } - Object.defineProperty(object, 'container', { - configurable: true, - enumerable: false, - get: function () { - _emberDebug.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 this[CONTAINER_OVERRIDE] || container; - }, - - set: function (value) { - _emberDebug.deprecate('Providing the `container` property to ' + this + ' is deprecated. Please use `Ember.setOwner` or `owner.ownerInjection()` instead to provide an owner to the instance being created.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); - - this[CONTAINER_OVERRIDE] = value; - - return value; - } - }); + Object.defineProperty(object, 'container', INJECTED_DEPRECATED_CONTAINER_DESC); } function destroyDestroyables(container) { var cache = container.cache; var keys = Object.keys(cache); @@ -3661,11 +3663,11 @@ function buildFakeContainerFunction(container, containerProperty, ownerProperty) { return function () { _emberDebug.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', + until: '2.13.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' }); return container[containerProperty].apply(container, arguments); }; } @@ -3691,17 +3693,26 @@ var FactoryManager = (function () { function FactoryManager(container, factory, fullName, normalizedName) { babelHelpers.classCallCheck(this, FactoryManager); this.container = container; + this.owner = container.owner; this.class = factory; this.fullName = fullName; this.normalizedName = normalizedName; this.madeToString = undefined; this.injections = undefined; } + FactoryManager.prototype.toString = function toString() { + if (!this.madeToString) { + this.madeToString = this.container.registry.makeToString(this.class, this.fullName); + } + + return this.madeToString; + }; + FactoryManager.prototype.create = function create() { var _this = this; var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; @@ -3712,12 +3723,10 @@ this.injections = injections; } } var props = _emberUtils.assign({}, injections, options); - props[_emberUtils.NAME_KEY] = this.madeToString || (this.madeToString = this.container.registry.makeToString(this.class, this.fullName)); - _emberDebug.runInDebug(function () { var lazyInjections = undefined; var validationCache = _this.container.validationCache; // Ensure that all lazy injections are valid at instantiation time if (!validationCache[_this.fullName] && _this.class && typeof _this.class._lazyInjections === 'function') { @@ -3737,10 +3746,25 @@ var prototype = this.class.prototype; if (prototype) { injectDeprecatedContainer(prototype, this.container); } + // required to allow access to things like + // the customized toString, _debugContainerKey, + // owner, etc. without a double extend and without + // modifying the objects properties + if (typeof this.class._initFactory === 'function') { + this.class._initFactory(this); + } else { + // in the non-Ember.Object case we need to still setOwner + // this is required for supporting glimmer environment and + // template instantiation which rely heavily on + // `options[OWNER]` being passed into `create` + // TODO: clean this up, and remove in future versions + _emberUtils.setOwner(props, this.owner); + } + return this.class.create(props); }; return FactoryManager; })(); @@ -5329,11 +5353,11 @@ var instance = this; return { lookup: function () { _emberDebug.deprecate('Using `ApplicationInstance.container.lookup` is deprecated. Please use `ApplicationInstance.lookup` instead.', false, { id: 'ember-application.app-instance-container', - until: '3.0.0', + until: '2.13.0', url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-applicationinstance-container' }); return instance.lookup.apply(instance, arguments); } }; @@ -18975,27 +18999,21 @@ return _emberMetalComputed.cacheFor.get(cache, key); } } } - function finishChains(obj) { - // We only create meta if we really have to - var m = _emberMetalMeta.peekMeta(obj); - if (m !== undefined) { - m = _emberMetalMeta.meta(obj); - - // finish any current chains node watchers that reference obj - var chainWatchers = m.readableChainWatchers(); - if (chainWatchers !== undefined) { - chainWatchers.revalidateAll(); - } - // ensure that if we have inherited any chains they have been - // copied onto our own meta. - if (m.readableChains() !== undefined) { - m.writableChains(_emberMetalWatch_path.makeChainNode); - } + function finishChains(meta) { + // finish any current chains node watchers that reference obj + var chainWatchers = meta.readableChainWatchers(); + if (chainWatchers !== undefined) { + chainWatchers.revalidateAll(); } + // ensure that if we have inherited any chains they have been + // copied onto our own meta. + if (meta.readableChains() !== undefined) { + meta.writableChains(_emberMetalWatch_path.makeChainNode); + } } exports.removeChainWatcher = removeChainWatcher; exports.ChainNode = ChainNode; }); @@ -19758,11 +19776,11 @@ // To maintain stacktrace consistency across browsers var getStack = function (error) { var stack = error.stack; var message = error.message; - if (stack && !stack.includes(message)) { + if (stack && stack.indexOf(message) === -1) { stack = message + '\n' + stack; } return stack; }; @@ -20351,10 +20369,11 @@ exports.propertyDidChange = _emberMetalProperty_events.propertyDidChange; exports.propertyWillChange = _emberMetalProperty_events.propertyWillChange; exports.PROPERTY_DID_CHANGE = _emberMetalProperty_events.PROPERTY_DID_CHANGE; exports.defineProperty = _emberMetalProperties.defineProperty; exports.Descriptor = _emberMetalProperties.Descriptor; + exports._hasCachedComputedProperties = _emberMetalProperties._hasCachedComputedProperties; exports.watchKey = _emberMetalWatch_key.watchKey; exports.unwatchKey = _emberMetalWatch_key.unwatchKey; exports.ChainNode = _emberMetalChains.ChainNode; exports.finishChains = _emberMetalChains.finishChains; exports.removeChainWatcher = _emberMetalChains.removeChainWatcher; @@ -21611,10 +21630,11 @@ this._deps = undefined; this._chainWatchers = undefined; this._chains = undefined; this._tag = undefined; this._tags = undefined; + this._factory = undefined; // initial value for all flags right now is false // see FLAGS const for detailed list of flags used this._flags = 0; @@ -21859,10 +21879,19 @@ } else { obj[key] = value; } }; + babelHelpers.createClass(Meta, [{ + key: 'factory', + set: function (factory) { + this._factory = factory; + }, + get: function () { + return this._factory; + } + }]); return Meta; })(); exports.Meta = Meta; @@ -23526,10 +23555,11 @@ exports.Descriptor = Descriptor; exports.MANDATORY_SETTER_FUNCTION = MANDATORY_SETTER_FUNCTION; exports.DEFAULT_GETTER_FUNCTION = DEFAULT_GETTER_FUNCTION; exports.INHERITING_GETTER_FUNCTION = INHERITING_GETTER_FUNCTION; exports.defineProperty = defineProperty; + exports._hasCachedComputedProperties = _hasCachedComputedProperties; // .......................................................... // DESCRIPTOR // @@ -23648,28 +23678,24 @@ @param {*} [data] something other than a descriptor, that will become the explicit value of this property. */ function defineProperty(obj, keyName, desc, data, meta) { - var possibleDesc = undefined, - existingDesc = undefined, - watching = undefined, - value = undefined; - if (!meta) { meta = _emberMetalMeta.meta(obj); } var watchEntry = meta.peekWatching(keyName); - possibleDesc = obj[keyName]; - existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; + var possibleDesc = obj[keyName]; + var existingDesc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; - watching = watchEntry !== undefined && watchEntry > 0; + var watching = watchEntry !== undefined && watchEntry > 0; if (existingDesc) { existingDesc.teardown(obj, keyName); } + var value = undefined; if (desc instanceof Descriptor) { value = desc; if (true) { if (watching) { Object.defineProperty(obj, keyName, { @@ -23682,11 +23708,14 @@ obj[keyName] = value; } } else { obj[keyName] = value; } - if (desc.setup) { + + didDefineComputedProperty(obj.constructor); + + if (typeof desc.setup === 'function') { desc.setup(obj, keyName); } } else { if (desc == null) { value = data; @@ -23727,17 +23756,34 @@ _emberMetalProperty_events.overrideChains(obj, keyName, meta); } // The `value` passed to the `didDefineProperty` hook is // either the descriptor or data, whichever was passed. - if (obj.didDefineProperty) { + if (typeof obj.didDefineProperty === 'function') { obj.didDefineProperty(obj, keyName, value); } return this; } + var hasCachedComputedProperties = false; + + function _hasCachedComputedProperties() { + hasCachedComputedProperties = true; + } + + function didDefineComputedProperty(constructor) { + if (hasCachedComputedProperties === false) { + return; + } + var cache = _emberMetalMeta.meta(constructor).readableCache(); + + if (cache && cache._computedProperties !== undefined) { + cache._computedProperties = undefined; + } + } + function handleBrokenPhantomDefineProperty(obj, keyName, desc) { // https://github.com/ariya/phantomjs/issues/11856 Object.defineProperty(obj, keyName, { configurable: true, writable: true, value: 'iCry' }); Object.defineProperty(obj, keyName, desc); } @@ -25662,12 +25708,22 @@ /** Defines which query parameters the controller accepts. If you give the names `['category','page']` it will bind the values of these query parameters to the variables - `this.category` and `this.page` - @property queryParams + `this.category` and `this.page`. + By default, Ember coerces query parameter values using `toggleProperty`. + This behavior may lead to unexpected results. + To explicity configure a query parameter property so it coerces as expected, you must define a type property: + ```javascript + queryParams: [{ + category: { + type: 'boolean' + } + }] + ``` + @property queryParams @public */ queryParams: null, /** @@ -38351,22 +38407,22 @@ var schedule = _emberMetal.run.schedule; var applyMixin = _emberMetal.Mixin._apply; var finishPartial = _emberMetal.Mixin.finishPartial; var reopen = _emberMetal.Mixin.prototype.reopen; - var hasCachedComputedProperties = false; var POST_INIT = _emberUtils.symbol('POST_INIT'); exports.POST_INIT = POST_INIT; function makeCtor() { // Note: avoid accessing any properties on the object since it makes the // method a lot faster. This is glue code so we want it to be as fast as // possible. var wasApplied = false; - var initProperties = undefined; + var initProperties = undefined, + initFactory = undefined; var Class = (function () { function Class() { babelHelpers.classCallCheck(this, Class); @@ -38380,10 +38436,15 @@ this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY); var m = _emberMetal.meta(this); var proto = m.proto; m.proto = this; + + if (initFactory) { + m.factory = initFactory; + initFactory = null; + } if (initProperties) { // capture locally so we can clear the closed over variable var props = initProperties; initProperties = null; @@ -38461,11 +38522,11 @@ this.init.apply(this, arguments); this[POST_INIT](); m.proto = proto; - _emberMetal.finishChains(this); + _emberMetal.finishChains(m); _emberMetal.sendEvent(this, 'init'); } Class.willReopen = function willReopen() { if (wasApplied) { @@ -38477,10 +38538,14 @@ Class._initProperties = function _initProperties(args) { initProperties = args; }; + Class._initFactory = function _initFactory(factory) { + initFactory = factory; + }; + Class.proto = function proto() { var superclass = Class.superclass; if (superclass) { superclass.proto(); } @@ -38599,12 +38664,13 @@ from.to(to).connect(this); return from; }, _Mixin$create.toString = function () { var hasToStringExtension = typeof this.toStringExtension === 'function'; var extension = hasToStringExtension ? ':' + this.toStringExtension() : ''; - var ret = '<' + (this[_emberUtils.NAME_KEY] || this.constructor.toString()) + ':' + _emberUtils.guidFor(this) + extension + '>'; + var ret = '<' + (this[_emberUtils.NAME_KEY] || _emberMetal.meta(this).factory || this.constructor.toString()) + ':' + _emberUtils.guidFor(this) + extension + '>'; + return ret; }, _Mixin$create)); CoreObject.PrototypeMixin.ownerConstructor = CoreObject; @@ -38678,11 +38744,11 @@ var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined; _emberDebug.assert('metaForProperty() could not find a computed property with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty); return desc._meta || {}; }, _ClassMixinProps._computedProperties = _emberMetal.computed(function () { - hasCachedComputedProperties = true; + _emberMetal._hasCachedComputedProperties(); var proto = this.proto(); var property = undefined; var properties = []; for (var _name in proto) { @@ -38750,26 +38816,10 @@ ClassMixin.ownerConstructor = CoreObject; CoreObject.ClassMixin = ClassMixin; ClassMixin.apply(CoreObject); - - CoreObject.reopen({ - didDefineProperty: function (proto, key, value) { - if (hasCachedComputedProperties === false) { - return; - } - if (value instanceof _emberMetal.ComputedProperty) { - var cache = _emberMetal.meta(this.constructor).readableCache(); - - if (cache && cache._computedProperties !== undefined) { - cache._computedProperties = undefined; - } - } - } - }); - exports.default = CoreObject; }); // Private, and only for didInitAttrs willRecieveAttrs /** @@ -39758,10 +39808,15 @@ @submodule ember-runtime */ 'use strict'; + var _CoreObject$extend; + + var OVERRIDE_CONTAINER_KEY = _emberUtils.symbol('OVERRIDE_CONTAINER_KEY'); + var OVERRIDE_OWNER = _emberUtils.symbol('OVERRIDE_OWNER'); + /** `Ember.Object` is the main base class for all Ember objects. It is a subclass of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details, see the documentation for each of these. @@ -39769,11 +39824,51 @@ @namespace Ember @extends Ember.CoreObject @uses Ember.Observable @public */ - var EmberObject = _emberRuntimeSystemCore_object.default.extend(_emberRuntimeMixinsObservable.default); + var EmberObject = _emberRuntimeSystemCore_object.default.extend(_emberRuntimeMixinsObservable.default, (_CoreObject$extend = { + _debugContainerKey: _emberMetal.descriptor({ + enumerable: false, + get: function () { + if (this[OVERRIDE_CONTAINER_KEY]) { + return this[OVERRIDE_CONTAINER_KEY]; + } + + var meta = _emberMetal.meta(this); + var factory = meta.factory; + + return factory && factory.fullName; + }, + + // we need a setter here largely to support the legacy + // `owner._lookupFactory` and its double extend + set: function (value) { + this[OVERRIDE_CONTAINER_KEY] = value; + } + }) + + }, _CoreObject$extend[_emberUtils.OWNER] = _emberMetal.descriptor({ + enumerable: false, + get: function () { + if (this[OVERRIDE_OWNER]) { + return this[OVERRIDE_OWNER]; + } + + var meta = _emberMetal.meta(this); + var factory = meta.factory; + + return factory && factory.owner; + }, + + // we need a setter here largely to support the legacy + // `owner._lookupFactory` and its double extend + set: function (value) { + this[OVERRIDE_OWNER] = value; + } + }), _CoreObject$extend)); + EmberObject.toString = function () { return 'Ember.Object'; }; var FrameworkObject = EmberObject; @@ -42781,17 +42876,44 @@ 'use strict'; exports.default = toString; var objectToString = Object.prototype.toString; + function isNone(obj) { + return obj === null || obj === undefined; + } + /* A `toString` util function that supports objects without a `toString` method, e.g. an object created with `Object.create(null)`. */ function toString(obj) { - if (obj && typeof obj.toString === 'function') { + var type = typeof obj; + if (type === "string") { + return obj; + } + + if (Array.isArray(obj)) { + // Reimplement Array.prototype.join according to spec (22.1.3.13) + // Changing ToString(element) with this safe version of ToString. + var len = obj.length; + var sep = ','; + var r = ''; + + for (var k = 0; k < len; k++) { + if (k > 0) { + r += ','; + } + + if (!isNone(obj[k])) { + r += toString(obj[k]); + } + } + + return r; + } else if (obj != null && typeof obj.toString === 'function') { return obj.toString(); } else { return objectToString.call(obj); } } @@ -45451,10 +45573,10 @@ // reduced computed macros enifed("ember/version", ["exports"], function (exports) { "use strict"; - exports.default = "2.13.0-beta.2"; + exports.default = "2.13.0"; }); enifed('internal-test-helpers/apply-mixins', ['exports', 'ember-utils'], function (exports, _emberUtils) { 'use strict'; exports.default = applyMixins;