dist/ember-runtime.js in ember-source-1.10.0.beta.3 vs dist/ember-runtime.js in ember-source-1.10.0.beta.4

- old
+ new

@@ -3,11 +3,11 @@ * @copyright Copyright 2011-2014 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 1.10.0-beta.3 + * @version 1.10.0-beta.4 */ (function() { var define, requireModule, require, requirejs, Ember; @@ -4850,11 +4850,11 @@ The core Runtime framework is based on the jQuery API with a number of performance optimizations. @class Ember @static - @version 1.10.0-beta.3 + @version 1.10.0-beta.4 */ if ('undefined' === typeof Ember) { // Create core object. Make it act like an instance of Ember.Namespace so that // objects assigned to it are given a sane string representation. @@ -4877,14 +4877,14 @@ /** @property VERSION @type String - @default '1.10.0-beta.3' + @default '1.10.0-beta.4' @static */ - Ember.VERSION = '1.10.0-beta.3'; + Ember.VERSION = '1.10.0-beta.4'; /** Standard environmental variables. You can define these in a global `EmberENV` variable before loading Ember to control various configuration settings. @@ -6011,13 +6011,14 @@ Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` @method getProperties - @param obj + @for Ember + @param {Object} obj @param {String...|Array} list of keys to get - @return {Hash} + @return {Object} */ __exports__["default"] = function getProperties(obj) { var ret = {}; var propertyNames = arguments; var i = 1; @@ -10552,55 +10553,120 @@ ["./stream","exports"], function(__dependency1__, __exports__) { "use strict"; var Stream = __dependency1__["default"]; + /** + Check whether an object is a stream or not + + @private + @function isStream + @param {Object|Stream} object object to check whether it is a stream + @return {Boolean} `true` if the object is a stream, `false` otherwise + */ function isStream(object) { return object && object.isStream; } - __exports__.isStream = isStream;function subscribe(object, callback, context) { + __exports__.isStream = isStream;/** + A method of subscribing to a stream which is safe for use with a non-stream + object. If a non-stream object is passed, the function does nothing. + + @private + @function subscribe + @param {Object|Stream} object object or stream to potentially subscribe to + @param {Function} callback function to run when stream value changes + @param {Object} [context] the callback will be executed with this context if it + is provided + */ + function subscribe(object, callback, context) { if (object && object.isStream) { object.subscribe(callback, context); } } - __exports__.subscribe = subscribe;function unsubscribe(object, callback, context) { + __exports__.subscribe = subscribe;/** + A method of unsubscribing from a stream which is safe for use with a non-stream + object. If a non-stream object is passed, the function does nothing. + + @private + @function unsubscribe + @param {Object|Stream} object object or stream to potentially unsubscribe from + @param {Function} callback function originally passed to `subscribe()` + @param {Object} [context] object originally passed to `subscribe()` + */ + function unsubscribe(object, callback, context) { if (object && object.isStream) { object.unsubscribe(callback, context); } } - __exports__.unsubscribe = unsubscribe;function read(object) { + __exports__.unsubscribe = unsubscribe;/** + Retrieve the value of a stream, or in the case a non-stream object is passed, + return the object itself. + + @private + @function read + @param {Object|Stream} object object to return the value of + @return the stream's current value, or the non-stream object itself + */ + function read(object) { if (object && object.isStream) { return object.value(); } else { return object; } } - __exports__.read = read;function readArray(array) { + __exports__.read = read;/** + Map an array, replacing any streams with their values. + + @private + @function readArray + @param {Array} array The array to read values from + @return {Array} a new array of the same length with the values of non-stream + objects mapped from their original positions untouched, and + the values of stream objects retaining their original position + and replaced with the stream's current value. + */ + function readArray(array) { var length = array.length; var ret = new Array(length); for (var i = 0; i < length; i++) { ret[i] = read(array[i]); } return ret; } - __exports__.readArray = readArray;function readHash(object) { + __exports__.readArray = readArray;/** + Map a hash, replacing any stream property values with the current value of that + stream. + + @private + @function readHash + @param {Object} object The hash to read keys and values from + @return {Object} a new object with the same keys as the passed object. The + property values in the new object are the original values in + the case of non-stream objects, and the streams' current + values in the case of stream objects. + */ + function readHash(object) { var ret = {}; for (var key in object) { ret[key] = read(object[key]); } return ret; } __exports__.readHash = readHash;/** - * @function scanArray - * @param array Array array given to a handlebars helper - * @return Boolean whether the array contains a stream/bound value + Check whether an array contains any stream values + + @private + @function scanArray + @param {Array} array array given to a handlebars helper + @return {Boolean} `true` if the array contains a stream/bound value, `false` + otherwise */ function scanArray(array) { var length = array.length; var containsStream = false; @@ -10613,14 +10679,18 @@ return containsStream; } __exports__.scanArray = scanArray;/** - * @function scanHash - * @param Object hash "hash" argument given to a handlebars helper - * @return Boolean whether the object contains a stream/bound value - */ + Check whether a hash has any stream property values + + @private + @function scanHash + @param {Object} hash "hash" argument given to a handlebars helper + @return {Boolean} `true` if the object contains a stream/bound value, `false` + otherwise + */ function scanHash(hash) { var containsStream = false; for (var prop in hash) { if (isStream(hash[prop])) { @@ -10630,41 +10700,84 @@ } return containsStream; } - __exports__.scanHash = scanHash;// TODO: Create subclass ConcatStream < Stream. Defer - // subscribing to streams until the value() is called. - function concat(array, key) { + __exports__.scanHash = scanHash;/** + Join an array, with any streams replaced by their current values + + @private + @function concat + @param {Array} array An array containing zero or more stream objects and + zero or more non-stream objects + @param {String} separator string to be used to join array elements + @return {String} String with array elements concatenated and joined by the + provided separator, and any stream array members having been + replaced by the current value of the stream + */ + function concat(array, separator) { + // TODO: Create subclass ConcatStream < Stream. Defer + // subscribing to streams until the value() is called. var hasStream = scanArray(array); if (hasStream) { var i, l; var stream = new Stream(function() { - return readArray(array).join(key); + return readArray(array).join(separator); }); for (i = 0, l=array.length; i < l; i++) { subscribe(array[i], stream.notify, stream); } return stream; } else { - return array.join(key); + return array.join(separator); } } - __exports__.concat = concat;function chainStream(value, fn) { + __exports__.concat = concat;/** + Generate a new stream by providing a source stream and a function that can + be used to transform the stream's value. In the case of a non-stream object, + returns the result of the function. + + The value to transform would typically be available to the function you pass + to `chain()` via scope. For example: + + ```javascript + var source = ...; // stream returning a number + // or a numeric (non-stream) object + var result = chain(source, function(){ + var currentValue = read(source); + return currentValue + 1; + }); + ``` + + In the example, result is a stream if source is a stream, or a number of + source was numeric. + + @private + @function chain + @param {Object|Stream} value A stream or non-stream object + @param {Function} fn function to be run when the stream value changes, or to + be run once in the case of a non-stream object + @return {Object|Stream} In the case of a stream `value` parameter, a new + stream that will be updated with the return value of + the provided function `fn`. In the case of a + non-stream object, the return value of the provided + function `fn`. + */ + function chain(value, fn) { if (isStream(value)) { var stream = new Stream(fn); subscribe(value, stream.notify, stream); return stream; } else { return fn(); } } - __exports__.chainStream = chainStream; + __exports__.chain = chain; }); define("ember-metal/utils", ["ember-metal/core","ember-metal/platform","ember-metal/array","exports"], function(__dependency1__, __dependency2__, __dependency3__, __exports__) { // Remove "use strict"; from transpiled module until @@ -16171,11 +16284,11 @@ reject: function(value) { get(this, '_deferred').reject(value); }, _deferred: computed(function() { - Ember.deprecate('Usage of Ember.DeferredMixin or Ember.Deferred is deprecated.', this._suppressDeferredDeprecation); + Ember.deprecate('Usage of Ember.DeferredMixin or Ember.Deferred is deprecated.', this._suppressDeferredDeprecation, { url: 'http://emberjs.com/guides/deprecations/#toc_deprecate-ember-deferredmixin-and-ember-deferred' }); return RSVP.defer('Ember: DeferredMixin - ' + this); }) }); }); @@ -16939,31 +17052,31 @@ the enumerable. This method is often simpler/faster than using a callback. @method isAny @param {String} key the property to test @param {String} [value] optional value to test against. - @return {Boolean} `true` if the passed function returns `true` for any item + @return {Boolean} @since 1.3.0 */ isAny: function(key, value) { return this.any(apply(this, iter, arguments)); }, /** @method anyBy @param {String} key the property to test @param {String} [value] optional value to test against. - @return {Boolean} `true` if the passed function returns `true` for any item + @return {Boolean} @deprecated Use `isAny` instead */ anyBy: aliasMethod('isAny'), /** @method someProperty @param {String} key the property to test @param {String} [value] optional value to test against. - @return {Boolean} `true` if the passed function returns `true` for any item + @return {Boolean} @deprecated Use `isAny` instead */ someProperty: aliasMethod('isAny'), /** @@ -18417,11 +18530,11 @@ this.propertyDidChange(keyName); return this; }, addBeforeObserver: function(key, target, method) { - Ember.deprecate('Before observers are deprecated and will be removed in a future release. If you want to keep track of previous values you have to implement it yourself. See http://emberjs.com/guides/deprecations#toc_deprecate-beforeobservers'); + Ember.deprecate('Before observers are deprecated and will be removed in a future release. If you want to keep track of previous values you have to implement it yourself.', false, { url: 'http://emberjs.com/guides/deprecations/#toc_deprecate-beforeobservers' }); addBeforeObserver(this, key, target, method); }, /** Adds an observer on a property. @@ -19660,12 +19773,12 @@ Container.set = set; __exports__["default"] = Container; }); define("ember-runtime/system/core_object", - ["ember-metal/core","ember-metal/property_get","ember-metal/utils","ember-metal/platform","ember-metal/chains","ember-metal/events","ember-metal/mixin","ember-metal/enumerable_utils","ember-metal/error","ember-metal/keys","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-runtime/inject","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __exports__) { + ["ember-metal/core","ember-metal/merge","ember-metal/property_get","ember-metal/utils","ember-metal/platform","ember-metal/chains","ember-metal/events","ember-metal/mixin","ember-metal/enumerable_utils","ember-metal/error","ember-metal/keys","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-runtime/inject","exports"], + function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __exports__) { // Remove "use strict"; from transpiled module until // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed // // REMOVE_USE_STRICT: true @@ -19673,42 +19786,43 @@ @module ember @submodule ember-runtime */ var Ember = __dependency1__["default"]; + var merge = __dependency2__["default"]; // Ember.assert, Ember.config // NOTE: this object should never be included directly. Instead use `Ember.Object`. // We only define this separately so that `Ember.Set` can depend on it. - var get = __dependency2__.get; - var guidFor = __dependency3__.guidFor; - var apply = __dependency3__.apply; - var o_create = __dependency4__.create; - var generateGuid = __dependency3__.generateGuid; - var GUID_KEY = __dependency3__.GUID_KEY; - var meta = __dependency3__.meta; - var makeArray = __dependency3__.makeArray; - var finishChains = __dependency5__.finishChains; - var sendEvent = __dependency6__.sendEvent; - var IS_BINDING = __dependency7__.IS_BINDING; - var Mixin = __dependency7__.Mixin; - var required = __dependency7__.required; - var indexOf = __dependency8__.indexOf; - var EmberError = __dependency9__["default"]; - var o_defineProperty = __dependency4__.defineProperty; - var keys = __dependency10__["default"]; - var ActionHandler = __dependency11__["default"]; - var defineProperty = __dependency12__.defineProperty; - var Binding = __dependency13__.Binding; - var ComputedProperty = __dependency14__.ComputedProperty; - var computed = __dependency14__.computed; - var InjectedProperty = __dependency15__["default"]; - var run = __dependency16__["default"]; - var destroy = __dependency17__.destroy; + var get = __dependency3__.get; + var guidFor = __dependency4__.guidFor; + var apply = __dependency4__.apply; + var o_create = __dependency5__.create; + var generateGuid = __dependency4__.generateGuid; + var GUID_KEY = __dependency4__.GUID_KEY; + var meta = __dependency4__.meta; + var makeArray = __dependency4__.makeArray; + var finishChains = __dependency6__.finishChains; + var sendEvent = __dependency7__.sendEvent; + var IS_BINDING = __dependency8__.IS_BINDING; + var Mixin = __dependency8__.Mixin; + var required = __dependency8__.required; + var indexOf = __dependency9__.indexOf; + var EmberError = __dependency10__["default"]; + var o_defineProperty = __dependency5__.defineProperty; + var keys = __dependency11__["default"]; + var ActionHandler = __dependency12__["default"]; + var defineProperty = __dependency13__.defineProperty; + var Binding = __dependency14__.Binding; + var ComputedProperty = __dependency15__.ComputedProperty; + var computed = __dependency15__.computed; + var InjectedProperty = __dependency16__["default"]; + var run = __dependency17__["default"]; + var destroy = __dependency18__.destroy; var K = __dependency1__.K; - var hasPropertyAccessors = __dependency4__.hasPropertyAccessors; - var validatePropertyInjections = __dependency18__.validatePropertyInjections; + var hasPropertyAccessors = __dependency5__.hasPropertyAccessors; + var validatePropertyInjections = __dependency19__.validatePropertyInjections; var schedule = run.schedule; var applyMixin = Mixin._apply; var finishPartial = Mixin.finishPartial; var reopen = Mixin.prototype.reopen; @@ -19756,10 +19870,11 @@ // capture locally so we can clear the closed over variable var props = initProperties; initProperties = null; var concatenatedProperties = this.concatenatedProperties; + var mergedProperties = this.mergedProperties; for (var i = 0, l = props.length; i < l; i++) { var properties = props[i]; Ember.assert("Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.", !(properties instanceof Mixin)); @@ -19808,10 +19923,18 @@ } else { value = makeArray(value); } } + if (mergedProperties && + mergedProperties.length && + indexOf(mergedProperties, keyName) >= 0) { + var originalValue = this[keyName]; + + value = merge(originalValue, value); + } + if (desc) { desc.set(this, keyName, value); } else { if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) { this.setUnknownProperty(keyName, value); @@ -19973,12 +20096,12 @@ classNames: 'baz' }) view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz'] ``` - Using the `concatenatedProperties` property, we can tell to Ember that mix - the content of the properties. + Using the `concatenatedProperties` property, we can tell Ember to mix the + content of the properties. In `Ember.View` the `classNameBindings` and `attributeBindings` properties are also concatenated, in addition to `classNames`. This feature is available for you to use throughout the Ember object model, @@ -20578,10 +20701,10 @@ var DeferredMixin = __dependency2__["default"]; var EmberObject = __dependency3__["default"]; var Deferred = EmberObject.extend(DeferredMixin, { init: function() { - Ember.deprecate('Usage of Ember.Deferred is deprecated.'); + Ember.deprecate('Usage of Ember.Deferred is deprecated.', false, { url: 'http://emberjs.com/guides/deprecations/#toc_deprecate-ember-deferredmixin-and-ember-deferred' }); this._super(); } }); Deferred.reopenClass({