dist/ember.prod.js in ember-source-2.4.0.beta.2 vs dist/ember.prod.js in ember-source-2.4.0.beta.3

- old
+ new

@@ -1,14 +1,14 @@ ;(function() { /*! * @overview Ember - JavaScript Application Framework - * @copyright Copyright 2011-2015 Tilde Inc. and contributors + * @copyright Copyright 2011-2016 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.4.0-beta.2 + * @version 2.4.0-beta.3 */ var enifed, requireModule, require, requirejs, Ember; var mainContext = this; @@ -210,24 +210,28 @@ }; }); enifed('backburner/platform', ['exports'], function (exports) { 'use strict'; - var platform; + var GlobalContext; /* global self */ if (typeof self === 'object') { - platform = self; + GlobalContext = self; /* global global */ } else if (typeof global === 'object') { - platform = global; - } else { - throw new Error('no global: `self` or `global` found'); - } + GlobalContext = global; - exports.default = platform; + /* global window */ + } else if (typeof window === 'object') { + GlobalContext = window; + } else { + throw new Error('no global: `self`, `global` nor `window` was found'); + } + + exports.default = GlobalContext; }); enifed('backburner/queue', ['exports', 'backburner/utils'], function (exports, _backburnerUtils) { 'use strict'; exports.default = Queue; @@ -466,27 +470,18 @@ exports.each = each; exports.isString = isString; exports.isFunction = isFunction; exports.isNumber = isNumber; exports.isCoercableNumber = isCoercableNumber; - exports.wrapInTryCatch = wrapInTryCatch; var NUMBER = /\d+/; function each(collection, callback) { for (var i = 0; i < collection.length; i++) { callback(collection[i]); } } - // Date.now is not available in browsers < IE9 - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility - var now = Date.now || function () { - return new Date().getTime(); - }; - - exports.now = now; - function isString(suspect) { return typeof suspect === 'string'; } function isFunction(suspect) { @@ -498,20 +493,10 @@ } function isCoercableNumber(number) { return isNumber(number) || NUMBER.test(number); } - - function wrapInTryCatch(func) { - return function () { - try { - return func.apply(this, arguments); - } catch (e) { - throw e; - } - }; - } }); enifed('backburner', ['exports', 'backburner/utils', 'backburner/platform', 'backburner/binary-search', 'backburner/deferred-action-queues'], function (exports, _backburnerUtils, _backburnerPlatform, _backburnerBinarySearch, _backburnerDeferredActionQueues) { 'use strict'; exports.default = Backburner; @@ -528,14 +513,20 @@ this._eventCallbacks = { end: [], begin: [] }; + var _this = this; + this._boundClearItems = function () { + clearItems(); + }; + this._timerTimeoutId = undefined; this._timers = []; - var _this = this; + this._platform = this.options._platform || _backburnerPlatform.default; + this._boundRunExpiredTimers = function () { _this._runExpiredTimers(); }; } @@ -868,11 +859,11 @@ } else { method = args.shift(); } } - var executeAt = _backburnerUtils.now() + parseInt(wait, 10); + var executeAt = Date.now() + parseInt(wait, 10); if (_backburnerUtils.isString(method)) { method = target[method]; } @@ -934,11 +925,11 @@ index = findThrottler(target, method, this._throttlers); if (index > -1) { return this._throttlers[index]; } // throttled - timer = _backburnerPlatform.default.setTimeout(function () { + timer = this._platform.setTimeout(function () { if (!immediate) { backburner.run.apply(backburner, args); } var index = findThrottler(target, method, backburner._throttlers); if (index > -1) { @@ -979,14 +970,14 @@ index = findDebouncee(target, method, this._debouncees); if (index > -1) { debouncee = this._debouncees[index]; this._debouncees.splice(index, 1); - clearTimeout(debouncee[2]); + this._platform.clearTimeout(debouncee[2]); } - timer = _backburnerPlatform.default.setTimeout(function () { + timer = this._platform.setTimeout(function () { if (!immediate) { backburner.run.apply(backburner, args); } var index = findDebouncee(target, method, backburner._debouncees); if (index > -1) { @@ -1004,21 +995,21 @@ return debouncee; }, cancelTimers: function () { - _backburnerUtils.each(this._throttlers, clearItems); + _backburnerUtils.each(this._throttlers, this._boundClearItems); this._throttlers = []; - _backburnerUtils.each(this._debouncees, clearItems); + _backburnerUtils.each(this._debouncees, this._boundClearItems); this._debouncees = []; this._clearTimerTimeout(); this._timers = []; if (this._autorun) { - clearTimeout(this._autorun); + this._platform.clearTimeout(this._autorun); this._autorun = null; } }, hasTimers: function () { @@ -1063,11 +1054,11 @@ item = array[index]; if (item[2] === timer[2]) { array.splice(index, 1); - clearTimeout(timer[2]); + this._platform.clearTimeout(timer[2]); return true; } } return false; @@ -1077,11 +1068,11 @@ this._timerTimeoutId = undefined; this.run(this, this._scheduleExpiredTimers); }, _scheduleExpiredTimers: function () { - var n = _backburnerUtils.now(); + var n = Date.now(); var timers = this._timers; var i = 0; var l = timers.length; for (; i < l; i += 2) { var executeAt = timers[i]; @@ -1103,22 +1094,22 @@ _clearTimerTimeout: function () { if (!this._timerTimeoutId) { return; } - clearTimeout(this._timerTimeoutId); + this._platform.clearTimeout(this._timerTimeoutId); this._timerTimeoutId = undefined; }, _installTimerTimeout: function () { if (!this._timers.length) { return; } var minExpiresAt = this._timers[0]; - var n = _backburnerUtils.now(); + var n = Date.now(); var wait = Math.max(0, minExpiresAt - n); - this._timerTimeoutId = setTimeout(this._boundRunExpiredTimers, wait); + this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait); } }; Backburner.prototype.schedule = Backburner.prototype.defer; Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce; @@ -1128,11 +1119,11 @@ return options.onError || options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]; } function createAutorun(backburner) { backburner.begin(); - backburner._autorun = _backburnerPlatform.default.setTimeout(function () { + backburner._autorun = backburner._platform.setTimeout(function () { backburner._autorun = null; backburner.end(); }); } @@ -1158,11 +1149,11 @@ return index; } function clearItems(item) { - clearTimeout(item[2]); + this._platform.clearTimeout(item[2]); } }); enifed('container/container', ['exports', 'ember-metal/core', 'ember-metal/debug', 'ember-metal/dictionary', 'ember-metal/features', 'container/owner', 'ember-runtime/mixins/container_proxy', 'ember-metal/symbol'], function (exports, _emberMetalCore, _emberMetalDebug, _emberMetalDictionary, _emberMetalFeatures, _containerOwner, _emberRuntimeMixinsContainer_proxy, _emberMetalSymbol) { 'use strict'; @@ -6183,11 +6174,11 @@ }); return types; } }); }); -enifed('ember-extension-support/data_adapter', ['exports', 'ember-metal/property_get', 'ember-metal/run_loop', 'ember-runtime/system/string', 'ember-runtime/system/namespace', 'ember-runtime/system/object', 'ember-runtime/system/native_array', 'ember-application/system/application', 'container/owner'], function (exports, _emberMetalProperty_get, _emberMetalRun_loop, _emberRuntimeSystemString, _emberRuntimeSystemNamespace, _emberRuntimeSystemObject, _emberRuntimeSystemNative_array, _emberApplicationSystemApplication, _containerOwner) { +enifed('ember-extension-support/data_adapter', ['exports', 'ember-metal/property_get', 'ember-metal/run_loop', 'ember-runtime/system/string', 'ember-runtime/system/namespace', 'ember-runtime/system/object', 'ember-runtime/system/native_array', 'ember-application/system/application', 'container/owner', 'ember-runtime/mixins/array'], function (exports, _emberMetalProperty_get, _emberMetalRun_loop, _emberRuntimeSystemString, _emberRuntimeSystemNamespace, _emberRuntimeSystemObject, _emberRuntimeSystemNative_array, _emberApplicationSystemApplication, _containerOwner, _emberRuntimeMixinsArray) { 'use strict'; /** @module ember @submodule ember-extension-support @@ -6374,11 +6365,11 @@ return _this2.wrapRecord(record); }); var contentDidChange = function (array, idx, removedCount, addedCount) { for (var i = idx; i < idx + addedCount; i++) { - var record = array.objectAt(i); + var record = _emberRuntimeMixinsArray.objectAt(array, i); var wrapped = _this2.wrapRecord(record); releaseMethods.push(_this2.observeRecord(record, recordUpdated)); recordsAdded([wrapped]); } @@ -6388,17 +6379,17 @@ }; var observer = { didChange: contentDidChange, willChange: function () { return this; } }; - records.addArrayObserver(this, observer); + _emberRuntimeMixinsArray.addArrayObserver(records, this, observer); release = function () { releaseMethods.forEach(function (fn) { fn(); }); - records.removeArrayObserver(_this2, observer); + _emberRuntimeMixinsArray.removeArrayObserver(records, _this2, observer); _this2.releaseMethods.removeObject(release); }; recordsAdded(recordsToSend); @@ -6469,14 +6460,14 @@ willChange: function () { return this; } }; - records.addArrayObserver(this, observer); + _emberRuntimeMixinsArray.addArrayObserver(records, this, observer); var release = function () { - records.removeArrayObserver(_this3, observer); + _emberRuntimeMixinsArray.removeArrayObserver(records, _this3, observer); }; return release; }, @@ -8405,13 +8396,15 @@ switch (path) { case 'unbound': return true; case 'unless': case 'if': - params[0] = shouldDisplay(params[0]);break; + params[0] = shouldDisplay(params[0], toBool);break; case 'each': params[0] = eachParam(params[0]);break; + case 'with': + params[0] = shouldDisplay(params[0], identity);break; } } // If has a dot in the path, we need to subscribe to the arguments in the // closure component as well. @@ -8457,11 +8450,11 @@ stream.addDependency(listChange); return stream; } - function shouldDisplay(predicate) { + function shouldDisplay(predicate, coercer) { var length = getKey(predicate, 'length'); var isTruthy = getKey(predicate, 'isTruthy'); var stream = _emberMetalStreamsUtils.chain(predicate, function () { var predicateVal = _emberMetalStreamsUtils.read(predicate); @@ -8474,19 +8467,27 @@ if (typeof isTruthyVal === 'boolean') { return isTruthyVal; } - return !!predicateVal; + return coercer(predicateVal); }, 'ShouldDisplay'); _emberMetalStreamsUtils.addDependency(stream, length); _emberMetalStreamsUtils.addDependency(stream, isTruthy); return stream; } + function toBool(value) { + return !!value; + } + + function identity(value) { + return value; + } + function getKey(obj, key) { if (_emberMetalStreamsUtils.isStream(obj)) { return obj.getKey(key); } else { return obj && obj[key]; @@ -9878,11 +9879,11 @@ @submodule ember-templates */ 'use strict'; - _emberHtmlbarsTemplatesTopLevelView.default.meta.revision = 'Ember@2.4.0-beta.2'; + _emberHtmlbarsTemplatesTopLevelView.default.meta.revision = 'Ember@2.4.0-beta.3'; /** The `{{outlet}}` helper lets you specify where a child routes will render in your template. An important use of the `{{outlet}}` helper is in your application's `application.hbs` file: @@ -15455,11 +15456,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.4.0-beta.2 + @version 2.4.0-beta.3 @public */ if ('undefined' === typeof Ember) { // Create core object. Make it act like an instance of Ember.Namespace so that @@ -15497,15 +15498,15 @@ /** The semantic version. @property VERSION @type String - @default '2.4.0-beta.2' + @default '2.4.0-beta.3' @static @public */ - Ember.VERSION = '2.4.0-beta.2'; + Ember.VERSION = '2.4.0-beta.3'; /** 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 @@ -17857,10 +17858,11 @@ readableChains */ var members = { cache: ownMap, + weak: ownMap, watching: inheritedMap, mixins: inheritedMap, bindings: inheritedMap, values: inheritedMap, deps: inheritedMapOfMaps, @@ -17871,10 +17873,11 @@ var memberNames = Object.keys(members); var META_FIELD = '__ember_meta__'; function Meta(obj, parentMeta) { this._cache = undefined; + this._weak = undefined; this._watching = undefined; this._mixins = undefined; this._bindings = undefined; this._values = undefined; this._deps = undefined; @@ -17955,11 +17958,11 @@ pointer = pointer.parent; } }; Meta.prototype['clear' + capitalized] = function () { - this[key] = new _emberMetalEmpty_object.default(); + this[key] = undefined; }; Meta.prototype['deleteFrom' + capitalized] = function (subkey) { delete this._getOrCreateOwnMap(key)[subkey]; }; @@ -19005,15 +19008,14 @@ return; } seen[_emberMetalUtils.guidFor(mixin)] = true; if (mixin.properties) { - var props = mixin.properties; - for (var key in props) { - if (props.hasOwnProperty(key)) { - ret[key] = true; - } + var props = Object.keys(mixin.properties); + for (var i = 0; i < props.length; i++) { + var key = props[i]; + ret[key] = true; } } else if (mixin.mixins) { mixin.mixins.forEach(function (x) { return _keys(ret, x, seen); }); @@ -19021,17 +19023,13 @@ } MixinPrototype.keys = function () { var keys = {}; var seen = {}; - var ret = []; + _keys(keys, this, seen); - for (var key in keys) { - if (keys.hasOwnProperty(key)) { - ret.push(key); - } - } + var ret = Object.keys(keys); return ret; }; // returns the mixins currently applied to the specified object // TODO: Make Ember.mixin @@ -22869,10 +22867,103 @@ } } } } }); +enifed('ember-metal/weak_map', ['exports', 'ember-metal/debug', 'ember-metal/utils', 'ember-metal/meta'], function (exports, _emberMetalDebug, _emberMetalUtils, _emberMetalMeta) { + 'use strict'; + + exports.default = WeakMap; + + var id = 0; + function UNDEFINED() {} + + /* + * @private + * @class Ember.WeakMap + * + * A partial polyfill for [WeakMap](http://www.ecma-international.org/ecma-262/6.0/#sec-weakmap-objects). + * + * There is a small but important caveat. This implementation assumes that the + * weak map will live longer (in the sense of garbage collection) than all of its + * keys, otherwise it is possible to leak the values stored in the weak map. In + * practice, most use cases satisfy this limitation which is why it is included + * in ember-metal. + */ + + function WeakMap() { + + this._id = _emberMetalUtils.GUID_KEY + id++; + } + + /* + * @method get + * @param key {Object | Function} + * @return {Any} stored value + */ + WeakMap.prototype.get = function (obj) { + var meta = _emberMetalMeta.peekMeta(obj); + if (meta) { + var map = meta.readableWeak(); + if (map) { + if (map[this._id] === UNDEFINED) { + return undefined; + } + + return map[this._id]; + } + } + }; + + /* + * @method set + * @param key {Object | Function} + * @param value {Any} + * @return {WeakMap} the weak map + */ + WeakMap.prototype.set = function (obj, value) { + + if (value === undefined) { + value = UNDEFINED; + } + + _emberMetalMeta.meta(obj).writableWeak()[this._id] = value; + + return this; + }; + + /* + * @method has + * @param key {Object | Function} + * @return {boolean} if the key exists + */ + WeakMap.prototype.has = function (obj) { + var meta = _emberMetalMeta.peekMeta(obj); + if (meta) { + var map = meta.readableWeak(); + if (map) { + return map[this._id] !== undefined; + } + } + + return false; + }; + + /* + * @method delete + * @param key {Object | Function} + * @return {boolean} if the key was deleted + */ + WeakMap.prototype.delete = function (obj) { + if (this.has(obj)) { + delete _emberMetalMeta.meta(obj).writableWeak()[this._id]; + return true; + } else { + return false; + } + }; +}); enifed('ember-metal-views/index', ['exports', 'ember-metal-views/renderer'], function (exports, _emberMetalViewsRenderer) { 'use strict'; exports.Renderer = _emberMetalViewsRenderer.default; }); @@ -23167,11 +23258,11 @@ _emberRuntimeMixinsController.default.reopen({ concatenatedProperties: ['queryParams'], /** Defines which query parameters the controller accepts. - If you give the names ['category','page'] it will bind + 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 @public */ @@ -27022,13 +27113,28 @@ return this._doURLTransition('handleURL', url); }, _doURLTransition: function (routerJsMethod, url) { var transition = this.router[routerJsMethod](url || '/'); - return didBeginTransition(transition, this); + didBeginTransition(transition, this); + return transition; }, + /** + Transition the application into another route. The route may + be either a single route or route path: + See [Route.transitionTo](http://emberjs.com/api/classes/Ember.Route.html#method_transitionTo) for more info. + @method transitionTo + @param {String} name the name of the route or a URL + @param {...Object} models the model(s) or identifier(s) to be used while + transitioning to the route. + @param {Object} [options] optional hash with a queryParams property + containing a mapping of query parameters + @return {Transition} the transition object associated with this + attempted transition + @private + */ transitionTo: function () { var queryParams; for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; @@ -27338,15 +27444,15 @@ var queryParams = {}; _emberMetalAssign.default(queryParams, _queryParams); this._prepareQueryParams(targetRouteName, models, queryParams); var transitionArgs = _emberRoutingUtils.routeArgs(targetRouteName, models, queryParams); - var transitionPromise = this.router.transitionTo.apply(this.router, transitionArgs); + var transition = this.router.transitionTo.apply(this.router, transitionArgs); - didBeginTransition(transitionPromise, this); + didBeginTransition(transition, this); - return transitionPromise; + return transition; }, _prepareQueryParams: function (targetRouteName, models, queryParams) { this._hydrateUnsuppliedQueryParams(targetRouteName, models, queryParams); this._serializeQueryParams(targetRouteName, queryParams); @@ -27793,11 +27899,11 @@ if (!router.currentState) { router.set('currentState', routerState); } router.set('targetState', routerState); - return transition.catch(function (error) { + transition.promise = transition.catch(function (error) { var errorId = _emberMetalUtils.guidFor(error); if (router._isErrorHandled(errorId)) { router._clearHandledError(errorId); } else { @@ -29280,11 +29386,11 @@ @submodule ember-routing-views */ 'use strict'; - _emberHtmlbarsTemplatesLinkTo.default.meta.revision = 'Ember@2.4.0-beta.2'; + _emberHtmlbarsTemplatesLinkTo.default.meta.revision = 'Ember@2.4.0-beta.3'; /** `Ember.LinkComponent` renders an element whose `click` event triggers a transition of the application's instance of `Ember.Router` to a supplied route by name. @@ -29780,11 +29886,11 @@ @submodule ember-routing-views */ 'use strict'; - _emberHtmlbarsTemplatesTopLevelView.default.meta.revision = 'Ember@2.4.0-beta.2'; + _emberHtmlbarsTemplatesTopLevelView.default.meta.revision = 'Ember@2.4.0-beta.3'; var CoreOutletView = _emberViewsViewsView.default.extend({ defaultTemplate: _emberHtmlbarsTemplatesTopLevelView.default, init: function () { @@ -29963,11 +30069,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', 'ember-metal/is_none', 'ember-metal/get_properties'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalError, _emberMetalComputed, _emberMetalObserver, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array, _emberMetalIs_none, _emberMetalGet_properties) { +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', 'ember-metal/weak_map'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalError, _emberMetalComputed, _emberMetalObserver, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array, _emberMetalIs_none, _emberMetalGet_properties, _emberMetalWeak_map) { /** @module ember @submodule ember-runtime */ @@ -30033,11 +30139,11 @@ return _emberMetalComputed.computed.apply(this, args).readOnly(); } /** - A computed property that returns the sum of the value + A computed property that returns the sum of the values in the dependent array. @method sum @for Ember.computed @param {String} dependentKey @@ -30624,71 +30730,83 @@ // depending on the sortProperties function propertySort(itemsKey, sortPropertiesKey) { var cp = new _emberMetalComputed.ComputedProperty(function (key) { var _this5 = this; - function didChange() { - this.notifyPropertyChange(key); - } - - var items = itemsKey === '@this' ? this : _emberMetalProperty_get.get(this, itemsKey); + var itemsKeyIsAtThis = itemsKey === '@this'; var sortProperties = _emberMetalProperty_get.get(this, sortPropertiesKey); - if (items === null || typeof items !== 'object') { - return _emberRuntimeSystemNative_array.A(); - } + var normalizedSortProperties = normalizeSortProperties(sortProperties); - // TODO: Ideally we'd only do this if things have changed - if (cp._sortPropObservers) { - cp._sortPropObservers.forEach(function (args) { - return _emberMetalObserver.removeObserver.apply(null, args); + // Add/remove property observers as required. + var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetalWeak_map.default()); + var activeObservers = activeObserversMap.get(this); + + if (activeObservers) { + activeObservers.forEach(function (args) { + _emberMetalObserver.removeObserver.apply(null, args); }); } - cp._sortPropObservers = []; - - if (!_emberRuntimeUtils.isArray(sortProperties)) { - return items; + function sortPropertyDidChange() { + this.notifyPropertyChange(key); } - // Normalize properties - var normalizedSort = sortProperties.map(function (p) { - var _p$split = p.split(':'); + activeObservers = normalizedSortProperties.map(function (_ref) { + var prop = _ref[0]; - var prop = _p$split[0]; - var direction = _p$split[1]; + var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop; + var args = [_this5, path, sortPropertyDidChange]; + _emberMetalObserver.addObserver.apply(null, args); + return args; + }); - direction = direction || 'asc'; + activeObserversMap.set(this, activeObservers); - return [prop, direction]; - }); + // Sort and return the array. + var items = itemsKeyIsAtThis ? this : _emberMetalProperty_get.get(this, itemsKey); - // TODO: Ideally we'd only do this if things have changed - // Add observers - normalizedSort.forEach(function (prop) { - var args = [_this5, itemsKey + '.@each.' + prop[0], didChange]; - cp._sortPropObservers.push(args); - _emberMetalObserver.addObserver.apply(null, args); - }); + if (_emberRuntimeUtils.isArray(items)) { + return sortByNormalizedSortProperties(items, normalizedSortProperties); + } else { + return _emberRuntimeSystemNative_array.A(); + } + }); - return _emberRuntimeSystemNative_array.A(items.slice().sort(function (itemA, itemB) { - for (var i = 0; i < normalizedSort.length; ++i) { - var _normalizedSort$i = normalizedSort[i]; - var prop = _normalizedSort$i[0]; - var direction = _normalizedSort$i[1]; + cp._activeObserverMap = undefined; - var result = _emberRuntimeCompare.default(_emberMetalProperty_get.get(itemA, prop), _emberMetalProperty_get.get(itemB, prop)); - if (result !== 0) { - return direction === 'desc' ? -1 * result : result; - } - } + return cp.property(sortPropertiesKey + '.[]').readOnly(); + } - return 0; - })); + function normalizeSortProperties(sortProperties) { + return sortProperties.map(function (p) { + var _p$split = p.split(':'); + + var prop = _p$split[0]; + var direction = _p$split[1]; + + direction = direction || 'asc'; + + return [prop, direction]; }); + } - return cp.property(itemsKey + '.[]', sortPropertiesKey + '.[]').readOnly(); + function sortByNormalizedSortProperties(items, normalizedSortProperties) { + return _emberRuntimeSystemNative_array.A(items.slice().sort(function (itemA, itemB) { + for (var i = 0; i < normalizedSortProperties.length; i++) { + var _normalizedSortProperties$i = normalizedSortProperties[i]; + var prop = _normalizedSortProperties$i[0]; + var direction = _normalizedSortProperties$i[1]; + + var result = _emberRuntimeCompare.default(_emberMetalProperty_get.get(itemA, prop), _emberMetalProperty_get.get(itemB, prop)); + if (result !== 0) { + return direction === 'desc' ? -1 * result : result; + } + } + + return 0; + })); } }); enifed('ember-runtime/controllers/controller', ['exports', 'ember-metal/debug', 'ember-runtime/system/object', 'ember-runtime/mixins/controller', 'ember-runtime/inject', 'ember-runtime/mixins/action_handler'], function (exports, _emberMetalDebug, _emberRuntimeSystemObject, _emberRuntimeMixinsController, _emberRuntimeInject, _emberRuntimeMixinsAction_handler) { 'use strict'; @@ -31723,10 +31841,14 @@ // .......................................................... // HELPERS // 'use strict'; + exports.addArrayObserver = addArrayObserver; + exports.removeArrayObserver = removeArrayObserver; + exports.objectAt = objectAt; + function arrayObserversHelper(obj, target, opts, operation, notify) { var willChange = opts && opts.willChange || 'arrayWillChange'; var didChange = opts && opts.didChange || 'arrayDidChange'; var hasObservers = _emberMetalProperty_get.get(obj, 'hasArrayObservers'); @@ -31742,10 +31864,26 @@ } return obj; } + function addArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, _emberMetalEvents.addListener, false); + } + + function removeArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, _emberMetalEvents.removeListener, true); + } + + function objectAt(content, idx) { + if (content.objectAt) { + return content.objectAt(idx); + } + + return content[idx]; + } + // .......................................................... // ARRAY // /** This mixin implements Observer-friendly Array-like behavior. It is not a @@ -31834,20 +31972,20 @@ @param {Array} indexes An array of indexes of items to return. @return {Array} @public */ objectsAt: function (indexes) { - var self = this; + var _this = this; return indexes.map(function (idx) { - return self.objectAt(idx); + return objectAt(_this, idx); }); }, // overrides Ember.Enumerable version nextObject: function (idx) { - return this.objectAt(idx); + return objectAt(this, idx); }, /** This is the handler for the special array content property. If you get this property, it will return this. If you set this property to a new @@ -31866,15 +32004,15 @@ return this; } }), firstObject: _emberMetalComputed.computed(function () { - return this.objectAt(0); + return objectAt(this, 0); }), lastObject: _emberMetalComputed.computed(function () { - return this.objectAt(_emberMetalProperty_get.get(this, 'length') - 1); + return objectAt(this, _emberMetalProperty_get.get(this, 'length') - 1); }), // optimized version from Enumerable contains: function (obj) { return this.indexOf(obj) >= 0; @@ -31916,11 +32054,11 @@ if (endIndex < 0) { endIndex = length + endIndex; } while (beginIndex < endIndex) { - ret[ret.length] = this.objectAt(beginIndex++); + ret[ret.length] = objectAt(this, beginIndex++); } return ret; }, @@ -31955,11 +32093,11 @@ if (startAt < 0) { startAt += len; } for (idx = startAt; idx < len; idx++) { - if (this.objectAt(idx) === object) { + if (objectAt(this, idx) === object) { return idx; } } return -1; @@ -31996,11 +32134,11 @@ if (startAt < 0) { startAt += len; } for (idx = startAt; idx >= 0; idx--) { - if (this.objectAt(idx) === object) { + if (objectAt(this, idx) === object) { return idx; } } return -1; @@ -32031,11 +32169,11 @@ @return {Ember.Array} receiver @public */ addArrayObserver: function (target, opts) { - return arrayObserversHelper(this, target, opts, _emberMetalEvents.addListener, false); + return addArrayObserver(this, target, opts); }, /** Removes an array observer from the object if the observer is current registered. Calling this method multiple times with the same object will @@ -32046,11 +32184,11 @@ `willChange` and `didChange` option. @return {Ember.Array} receiver @public */ removeArrayObserver: function (target, opts) { - return arrayObserversHelper(this, target, opts, _emberMetalEvents.removeListener, true); + return removeArrayObserver(this, target, opts); }, /** Becomes true whenever the array currently has observers watching changes on the array. @@ -32101,11 +32239,11 @@ if (startIdx >= 0 && removeAmt >= 0 && _emberMetalProperty_get.get(this, 'hasEnumerableObservers')) { removing = []; lim = startIdx + removeAmt; for (var idx = startIdx; idx < lim; idx++) { - removing.push(this.objectAt(idx)); + removing.push(objectAt(this, idx)); } } else { removing = removeAmt; } @@ -32148,11 +32286,11 @@ if (startIdx >= 0 && addAmt >= 0 && _emberMetalProperty_get.get(this, 'hasEnumerableObservers')) { adding = []; lim = startIdx + addAmt; for (var idx = startIdx; idx < lim; idx++) { - adding.push(this.objectAt(idx)); + adding.push(objectAt(this, idx)); } } else { adding = addAmt; } @@ -32166,16 +32304,16 @@ var length = _emberMetalProperty_get.get(this, 'length'); var cachedFirst = _emberMetalComputed.cacheFor(this, 'firstObject'); var cachedLast = _emberMetalComputed.cacheFor(this, 'lastObject'); - if (this.objectAt(0) !== cachedFirst) { + if (objectAt(this, 0) !== cachedFirst) { _emberMetalProperty_events.propertyWillChange(this, 'firstObject'); _emberMetalProperty_events.propertyDidChange(this, 'firstObject'); } - if (this.objectAt(length - 1) !== cachedLast) { + if (objectAt(this, length - 1) !== cachedLast) { _emberMetalProperty_events.propertyWillChange(this, 'lastObject'); _emberMetalProperty_events.propertyDidChange(this, 'lastObject'); } return this; @@ -33925,11 +34063,11 @@ var len = _emberMetalProperty_get.get(this, 'length'); if (len === 0) { return null; } - var ret = this.objectAt(len - 1); + var ret = _emberRuntimeMixinsArray.objectAt(this, len - 1); this.removeAt(len - 1, 1); return ret; }, /** @@ -33947,11 +34085,11 @@ shiftObject: function () { if (_emberMetalProperty_get.get(this, 'length') === 0) { return null; } - var ret = this.objectAt(0); + var ret = _emberRuntimeMixinsArray.objectAt(this, 0); this.removeAt(0); return ret; }, /** @@ -34050,11 +34188,11 @@ @public */ removeObject: function (obj) { var loc = _emberMetalProperty_get.get(this, 'length') || 0; while (--loc >= 0) { - var curObject = this.objectAt(loc); + var curObject = _emberRuntimeMixinsArray.objectAt(this, loc); if (curObject === obj) { this.removeAt(loc); } } @@ -34232,12 +34370,13 @@ More documentation about `get` and `set` are below. ## Observing Property Changes - You typically observe property changes simply by adding the `observes` - call to the end of your method declarations in classes that you write. + You typically observe property changes simply by using the `Ember.observer` + function in classes that you write. + For example: ```javascript Ember.Object.extend({ valueObserver: Ember.observer('value', function(sender, key, value, rev) { @@ -35252,11 +35391,11 @@ enifed('ember-runtime/system/application', ['exports', 'ember-runtime/system/namespace'], function (exports, _emberRuntimeSystemNamespace) { 'use strict'; exports.default = _emberRuntimeSystemNamespace.default.extend(); }); -enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-runtime/utils', 'ember-metal/computed', 'ember-metal/mixin', 'ember-metal/property_events', 'ember-metal/error', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-metal/alias'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberRuntimeUtils, _emberMetalComputed, _emberMetalMixin, _emberMetalProperty_events, _emberMetalError, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberMetalAlias) { +enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-runtime/utils', 'ember-metal/computed', 'ember-metal/mixin', 'ember-metal/property_events', 'ember-metal/error', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-metal/alias', 'ember-runtime/mixins/array'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberRuntimeUtils, _emberMetalComputed, _emberMetalMixin, _emberMetalProperty_events, _emberMetalError, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberMetalAlias, _emberRuntimeMixinsArray) { 'use strict'; /** @module ember @submodule ember-runtime @@ -35337,11 +35476,11 @@ @param {Number} idx The index to retrieve. @return {Object} the value or undefined if none found @private */ objectAtContent: function (idx) { - return _emberMetalProperty_get.get(this, 'arrangedContent').objectAt(idx); + return _emberRuntimeMixinsArray.objectAt(_emberMetalProperty_get.get(this, 'arrangedContent'), idx); }, /** Should actually replace the specified objects on the content array. You can override this method in subclasses to transform the content item @@ -35371,11 +35510,11 @@ _teardownContent: function () { var content = _emberMetalProperty_get.get(this, 'content'); if (content) { - content.removeArrayObserver(this, { + _emberRuntimeMixinsArray.removeArrayObserver(content, this, { willChange: 'contentArrayWillChange', didChange: 'contentArrayDidChange' }); } }, @@ -35416,11 +35555,11 @@ _setupContent: function () { var content = _emberMetalProperty_get.get(this, 'content'); if (content) { - content.addArrayObserver(this, { + _emberRuntimeMixinsArray.addArrayObserver(content, this, { willChange: 'contentArrayWillChange', didChange: 'contentArrayDidChange' }); } }, @@ -35448,22 +35587,22 @@ _setupArrangedContent: function () { var arrangedContent = _emberMetalProperty_get.get(this, 'arrangedContent'); if (arrangedContent) { - arrangedContent.addArrayObserver(this, { + _emberRuntimeMixinsArray.addArrayObserver(arrangedContent, this, { willChange: 'arrangedContentArrayWillChange', didChange: 'arrangedContentArrayDidChange' }); } }, _teardownArrangedContent: function () { var arrangedContent = _emberMetalProperty_get.get(this, 'arrangedContent'); if (arrangedContent) { - arrangedContent.removeArrayObserver(this, { + _emberRuntimeMixinsArray.removeArrayObserver(arrangedContent, this, { willChange: 'arrangedContentArrayWillChange', didChange: 'arrangedContentArrayDidChange' }); } }, @@ -35532,11 +35671,11 @@ } // Get a list of indices in original content to remove for (i = start; i < start + len; i++) { // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent - indices.push(content.indexOf(arrangedContent.objectAt(i))); + indices.push(content.indexOf(_emberRuntimeMixinsArray.objectAt(arrangedContent, i))); } // Replace in reverse order since indices will change indices.sort(function (a, b) { return b - a; @@ -36434,11 +36573,11 @@ /** Provides lookup-time type validation for injected properties. @private @method _onLookup */ -enifed('ember-runtime/system/each_proxy', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/observer', 'ember-metal/property_events', 'ember-metal/empty_object'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalObserver, _emberMetalProperty_events, _emberMetalEmpty_object) { +enifed('ember-runtime/system/each_proxy', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/observer', 'ember-metal/property_events', 'ember-metal/empty_object', 'ember-runtime/mixins/array'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalObserver, _emberMetalProperty_events, _emberMetalEmpty_object, _emberRuntimeMixinsArray) { 'use strict'; /** This is the object instance returned when you get the `@each` property on an array. It uses the unknownProperty handler to automatically create @@ -36535,21 +36674,21 @@ } }; function addObserverForContentKey(content, keyName, proxy, idx, loc) { while (--loc >= idx) { - var item = content.objectAt(loc); + var item = _emberRuntimeMixinsArray.objectAt(content, loc); if (item) { _emberMetalObserver._addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); _emberMetalObserver.addObserver(item, keyName, proxy, 'contentKeyDidChange'); } } } function removeObserverForContentKey(content, keyName, proxy, idx, loc) { while (--loc >= idx) { - var item = content.objectAt(loc); + var item = _emberRuntimeMixinsArray.objectAt(content, loc); if (item) { _emberMetalObserver._removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange'); _emberMetalObserver.removeObserver(item, keyName, proxy, 'contentKeyDidChange'); } } @@ -38673,11 +38812,11 @@ options.plugins = plugins; options.buildMeta = function buildMeta(program) { return { fragmentReason: fragmentReason(program), - revision: 'Ember@2.4.0-beta.2', + revision: 'Ember@2.4.0-beta.3', loc: program.loc, moduleName: options.moduleName }; }; @@ -42507,21 +42646,21 @@ @method _contentDidChange */ _contentDidChange: _emberMetalMixin.observer('content', function () { var prevContent = this._prevContent; if (prevContent) { - prevContent.removeArrayObserver(this); + _emberRuntimeMixinsArray.removeArrayObserver(prevContent, this); } var len = prevContent ? _emberMetalProperty_get.get(prevContent, 'length') : 0; this.arrayWillChange(prevContent, 0, len); var content = _emberMetalProperty_get.get(this, 'content'); if (content) { this._prevContent = content; this._assertArrayLike(content); - content.addArrayObserver(this); + _emberRuntimeMixinsArray.addArrayObserver(content, this); } len = content ? _emberMetalProperty_get.get(content, 'length') : 0; this.arrayDidChange(content, 0, null, len); }), @@ -42543,11 +42682,11 @@ return; } var content = _emberMetalProperty_get.get(this, 'content'); if (content) { - content.removeArrayObserver(this); + _emberRuntimeMixinsArray.removeArrayObserver(content, this); } if (this._createdEmptyView) { this._createdEmptyView.destroy(); } @@ -42593,11 +42732,11 @@ itemViewClass = this.getAttr('itemViewClass') || _emberMetalProperty_get.get(this, 'itemViewClass'); itemViewClass = _emberViewsStreamsUtils.readViewFactory(itemViewClass, _containerOwner.getOwner(this)); for (idx = start; idx < start + added; idx++) { - item = content.objectAt(idx); + item = _emberRuntimeMixinsArray.objectAt(content, idx); itemViewProps._context = this.keyword ? this.get('context') : item; itemViewProps.content = item; itemViewProps.contentIndex = idx; view = this.createChildView(itemViewClass, itemViewProps); @@ -42739,11 +42878,11 @@ exports.DeprecatedCollectionView = DeprecatedCollectionView; }); enifed('ember-views/views/container_view', ['exports', 'ember-metal/core', 'ember-metal/debug', 'ember-runtime/mixins/mutable_array', 'ember-runtime/system/native_array', 'ember-views/views/view', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/mixin', 'ember-metal/events', 'ember-htmlbars/templates/container-view'], function (exports, _emberMetalCore, _emberMetalDebug, _emberRuntimeMixinsMutable_array, _emberRuntimeSystemNative_array, _emberViewsViewsView, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalMixin, _emberMetalEvents, _emberHtmlbarsTemplatesContainerView) { 'use strict'; - _emberHtmlbarsTemplatesContainerView.default.meta.revision = 'Ember@2.4.0-beta.2'; + _emberHtmlbarsTemplatesContainerView.default.meta.revision = 'Ember@2.4.0-beta.3'; /** @module ember @submodule ember-views */ @@ -43212,11 +43351,11 @@ var tagName = _emberMetalProperty_get.get(this, 'tagName'); return _emberViewsViewsCollection_view.CONTAINER_MAP[tagName]; }) }); }); -enifed('ember-views/views/select', ['exports', 'ember-metal/replace', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-views/views/view', 'ember-runtime/utils', 'ember-metal/is_none', 'ember-metal/computed', 'ember-runtime/system/native_array', 'ember-metal/mixin', 'ember-metal/properties', 'ember-htmlbars/templates/select', 'ember-htmlbars/templates/select-option', 'ember-htmlbars/templates/select-optgroup'], function (exports, _emberMetalReplace, _emberMetalProperty_get, _emberMetalProperty_set, _emberViewsViewsView, _emberRuntimeUtils, _emberMetalIs_none, _emberMetalComputed, _emberRuntimeSystemNative_array, _emberMetalMixin, _emberMetalProperties, _emberHtmlbarsTemplatesSelect, _emberHtmlbarsTemplatesSelectOption, _emberHtmlbarsTemplatesSelectOptgroup) { +enifed('ember-views/views/select', ['exports', 'ember-metal/replace', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-views/views/view', 'ember-runtime/utils', 'ember-metal/is_none', 'ember-metal/computed', 'ember-runtime/system/native_array', 'ember-metal/mixin', 'ember-metal/properties', 'ember-htmlbars/templates/select', 'ember-htmlbars/templates/select-option', 'ember-htmlbars/templates/select-optgroup', 'ember-runtime/mixins/array'], function (exports, _emberMetalReplace, _emberMetalProperty_get, _emberMetalProperty_set, _emberViewsViewsView, _emberRuntimeUtils, _emberMetalIs_none, _emberMetalComputed, _emberRuntimeSystemNative_array, _emberMetalMixin, _emberMetalProperties, _emberHtmlbarsTemplatesSelect, _emberHtmlbarsTemplatesSelectOption, _emberHtmlbarsTemplatesSelectOptgroup, _emberRuntimeMixinsArray) { /** @module ember @submodule ember-views */ @@ -43748,10 +43887,10 @@ } if (prompt) { selectedIndex -= 1; } - _emberMetalProperty_set.set(this, 'selection', content.objectAt(selectedIndex)); + _emberMetalProperty_set.set(this, 'selection', _emberRuntimeMixinsArray.objectAt(content, selectedIndex)); }, _selectedIndex: function (value) { var defaultIndex = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];