dist/ember-template-compiler.js in ember-source-1.13.12 vs dist/ember-template-compiler.js in ember-source-1.13.13
- old
+ new
@@ -3,11 +3,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 1.13.12
+ * @version 1.13.13
*/
(function() {
var enifed, requireModule, eriuqer, requirejs, Ember;
var mainContext = this;
@@ -1869,10 +1869,642 @@
exports.removeChainWatcher = removeChainWatcher;
exports.ChainNode = ChainNode;
});
// warn, assert, etc;
+enifed("ember-metal/computed", ["exports", "ember-metal/core", "ember-metal/property_set", "ember-metal/utils", "ember-metal/expand_properties", "ember-metal/error", "ember-metal/properties", "ember-metal/property_events", "ember-metal/dependent_keys"], function (exports, _emberMetalCore, _emberMetalProperty_set, _emberMetalUtils, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) {
+ "use strict";
+
+ /**
+ @module ember
+ @submodule ember-metal
+ */
+
+ var metaFor = _emberMetalUtils.meta;
+
+ function UNDEFINED() {}
+
+ // ..........................................................
+ // COMPUTED PROPERTY
+ //
+
+ /**
+ A computed property transforms an object's function into a property.
+
+ By default the function backing the computed property will only be called
+ once and the result will be cached. You can specify various properties
+ that your computed property depends on. This will force the cached
+ result to be recomputed if the dependencies are modified.
+
+ In the following example we declare a computed property (by calling
+ `.property()` on the fullName function) and setup the property
+ dependencies (depending on firstName and lastName). The fullName function
+ will be called once (regardless of how many times it is accessed) as long
+ as its dependencies have not changed. Once firstName or lastName are updated
+ any future calls (or anything bound) to fullName will incorporate the new
+ values.
+
+ ```javascript
+ var Person = Ember.Object.extend({
+ // these will be supplied by `create`
+ firstName: null,
+ lastName: null,
+
+ fullName: function() {
+ var firstName = this.get('firstName');
+ var lastName = this.get('lastName');
+
+ return firstName + ' ' + lastName;
+ }.property('firstName', 'lastName')
+ });
+
+ var tom = Person.create({
+ firstName: 'Tom',
+ lastName: 'Dale'
+ });
+
+ tom.get('fullName') // 'Tom Dale'
+ ```
+
+ You can also define what Ember should do when setting a computed property.
+ If you try to set a computed property, it will be invoked with the key and
+ value you want to set it to. You can also accept the previous value as the
+ third parameter.
+
+ ```javascript
+ var Person = Ember.Object.extend({
+ // these will be supplied by `create`
+ firstName: null,
+ lastName: null,
+
+ fullName: function(key, value, oldValue) {
+ // getter
+ if (arguments.length === 1) {
+ var firstName = this.get('firstName');
+ var lastName = this.get('lastName');
+
+ return firstName + ' ' + lastName;
+
+ // setter
+ } else {
+ var name = value.split(' ');
+
+ this.set('firstName', name[0]);
+ this.set('lastName', name[1]);
+
+ return value;
+ }
+ }.property('firstName', 'lastName')
+ });
+
+ var person = Person.create();
+
+ person.set('fullName', 'Peter Wagenet');
+ person.get('firstName'); // 'Peter'
+ person.get('lastName'); // 'Wagenet'
+ ```
+
+ @class ComputedProperty
+ @namespace Ember
+ @constructor
+ @public
+ */
+ function ComputedProperty(config, opts) {
+ this.isDescriptor = true;
+ if (typeof config === "function") {
+ config.__ember_arity = config.length;
+ this._getter = config;
+ if (config.__ember_arity > 1) {
+ _emberMetalCore["default"].deprecate("Using the same function as getter and setter is deprecated.", false, {
+ url: "http://emberjs.com/deprecations/v1.x/#toc_deprecate-using-the-same-function-as-getter-and-setter-in-computed-properties"
+ });
+ this._setter = config;
+ }
+ } else {
+ this._getter = config.get;
+ this._setter = config.set;
+ if (this._setter && this._setter.__ember_arity === undefined) {
+ this._setter.__ember_arity = this._setter.length;
+ }
+ }
+
+ this._dependentKeys = undefined;
+ this._suspended = undefined;
+ this._meta = undefined;
+
+ _emberMetalCore["default"].deprecate("Passing opts.cacheable to the CP constructor is deprecated. Invoke `volatile()` on the CP instead.", !opts || !opts.hasOwnProperty('cacheable'));
+ this._cacheable = opts && opts.cacheable !== undefined ? opts.cacheable : true; // TODO: Set always to `true` once this deprecation is gone.
+ this._dependentKeys = opts && opts.dependentKeys;
+ _emberMetalCore["default"].deprecate("Passing opts.readOnly to the CP constructor is deprecated. All CPs are writable by default. You can invoke `readOnly()` on the CP to change this.", !opts || !opts.hasOwnProperty('readOnly'));
+ this._readOnly = opts && (opts.readOnly !== undefined || !!opts.readOnly) || false; // TODO: Set always to `false` once this deprecation is gone.
+ }
+
+ ComputedProperty.prototype = new _emberMetalProperties.Descriptor();
+
+ var ComputedPropertyPrototype = ComputedProperty.prototype;
+
+ /**
+ Properties are cacheable by default. Computed property will automatically
+ cache the return value of your function until one of the dependent keys changes.
+
+ Call `volatile()` to set it into non-cached mode. When in this mode
+ the computed property will not automatically cache the return value.
+
+ However, if a property is properly observable, there is no reason to disable
+ caching.
+
+ @method cacheable
+ @param {Boolean} aFlag optional set to `false` to disable caching
+ @return {Ember.ComputedProperty} this
+ @chainable
+ @deprecated All computed properties are cacheble by default. Use `volatile()` instead to opt-out to caching.
+ @public
+ */
+ ComputedPropertyPrototype.cacheable = function (aFlag) {
+ _emberMetalCore["default"].deprecate('ComputedProperty.cacheable() is deprecated. All computed properties are cacheable by default.');
+ this._cacheable = aFlag !== false;
+ return this;
+ };
+
+ /**
+ Call on a computed property to set it into non-cached mode. When in this
+ mode the computed property will not automatically cache the return value.
+
+ ```javascript
+ var outsideService = Ember.Object.extend({
+ value: function() {
+ return OutsideService.getValue();
+ }.property().volatile()
+ }).create();
+ ```
+
+ @method volatile
+ @return {Ember.ComputedProperty} this
+ @chainable
+ @public
+ */
+ ComputedPropertyPrototype["volatile"] = function () {
+ this._cacheable = false;
+ return this;
+ };
+
+ /**
+ Call on a computed property to set it into read-only mode. When in this
+ mode the computed property will throw an error when set.
+
+ ```javascript
+ var Person = Ember.Object.extend({
+ guid: function() {
+ return 'guid-guid-guid';
+ }.property().readOnly()
+ });
+
+ var person = Person.create();
+
+ person.set('guid', 'new-guid'); // will throw an exception
+ ```
+
+ @method readOnly
+ @return {Ember.ComputedProperty} this
+ @chainable
+ @public
+ */
+ ComputedPropertyPrototype.readOnly = function (readOnly) {
+ _emberMetalCore["default"].deprecate('Passing arguments to ComputedProperty.readOnly() is deprecated.', arguments.length === 0);
+ this._readOnly = readOnly === undefined || !!readOnly; // Force to true once this deprecation is gone
+ _emberMetalCore["default"].assert("Computed properties that define a setter using the new syntax cannot be read-only", !(this._readOnly && this._setter && this._setter !== this._getter));
+ return this;
+ };
+
+ /**
+ Sets the dependent keys on this computed property. Pass any number of
+ arguments containing key paths that this computed property depends on.
+
+ ```javascript
+ var President = Ember.Object.extend({
+ fullName: computed(function() {
+ return this.get('firstName') + ' ' + this.get('lastName');
+
+ // Tell Ember that this computed property depends on firstName
+ // and lastName
+ }).property('firstName', 'lastName')
+ });
+
+ var president = President.create({
+ firstName: 'Barack',
+ lastName: 'Obama'
+ });
+
+ president.get('fullName'); // 'Barack Obama'
+ ```
+
+ @method property
+ @param {String} path* zero or more property paths
+ @return {Ember.ComputedProperty} this
+ @chainable
+ @public
+ */
+ ComputedPropertyPrototype.property = function () {
+ var args;
+
+ var addArg = function (property) {
+ _emberMetalCore["default"].deprecate("Depending on arrays using a dependent key ending with `@each` is deprecated. " + ("Please refactor from `Ember.computed('" + property + "', function() {});` to `Ember.computed('" + property.slice(0, -6) + ".[]', function() {})`."), property.slice(-5) !== '@each', { id: 'ember-metal.@each-dependent-key-leaf', until: '2.0.0' });
+
+ args.push(property);
+ };
+
+ args = [];
+ for (var i = 0, l = arguments.length; i < l; i++) {
+ _emberMetalExpand_properties["default"](arguments[i], addArg);
+ }
+
+ this._dependentKeys = args;
+ return this;
+ };
+
+ /**
+ In some cases, you may want to annotate computed properties with additional
+ metadata about how they function or what values they operate on. For example,
+ computed property functions may close over variables that are then no longer
+ available for introspection.
+
+ You can pass a hash of these values to a computed property like this:
+
+ ```
+ person: function() {
+ var personId = this.get('personId');
+ return App.Person.create({ id: personId });
+ }.property().meta({ type: App.Person })
+ ```
+
+ The hash that you pass to the `meta()` function will be saved on the
+ computed property descriptor under the `_meta` key. Ember runtime
+ exposes a public API for retrieving these values from classes,
+ via the `metaForProperty()` function.
+
+ @method meta
+ @param {Object} meta
+ @chainable
+ @public
+ */
+
+ ComputedPropertyPrototype.meta = function (meta) {
+ if (arguments.length === 0) {
+ return this._meta || {};
+ } else {
+ this._meta = meta;
+ return this;
+ }
+ };
+
+ /* impl descriptor API */
+ ComputedPropertyPrototype.didChange = function (obj, keyName) {
+ // _suspended is set via a CP.set to ensure we don't clear
+ // the cached value set by the setter
+ if (this._cacheable && this._suspended !== obj) {
+ var meta = metaFor(obj);
+ if (meta.cache && meta.cache[keyName] !== undefined) {
+ meta.cache[keyName] = undefined;
+ _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta);
+ }
+ }
+ };
+
+ function finishChains(chainNodes) {
+ for (var i = 0, l = chainNodes.length; i < l; i++) {
+ chainNodes[i].didChange(null);
+ }
+ }
+
+ /**
+ Access the value of the function backing the computed property.
+ If this property has already been cached, return the cached result.
+ Otherwise, call the function passing the property name as an argument.
+
+ ```javascript
+ var Person = Ember.Object.extend({
+ fullName: function(keyName) {
+ // the keyName parameter is 'fullName' in this case.
+ return this.get('firstName') + ' ' + this.get('lastName');
+ }.property('firstName', 'lastName')
+ });
+
+
+ var tom = Person.create({
+ firstName: 'Tom',
+ lastName: 'Dale'
+ });
+
+ tom.get('fullName') // 'Tom Dale'
+ ```
+
+ @method get
+ @param {String} keyName The key being accessed.
+ @return {Object} The return value of the function backing the CP.
+ @public
+ */
+ ComputedPropertyPrototype.get = function (obj, keyName) {
+ var ret, cache, meta, chainNodes;
+ if (this._cacheable) {
+ meta = metaFor(obj);
+ cache = meta.cache;
+
+ var result = cache && cache[keyName];
+
+ if (result === UNDEFINED) {
+ return undefined;
+ } else if (result !== undefined) {
+ return result;
+ }
+
+ ret = this._getter.call(obj, keyName);
+ cache = meta.cache;
+ if (!cache) {
+ cache = meta.cache = {};
+ }
+ if (ret === undefined) {
+ cache[keyName] = UNDEFINED;
+ } else {
+ cache[keyName] = ret;
+ }
+
+ chainNodes = meta.chainWatchers && meta.chainWatchers[keyName];
+ if (chainNodes) {
+ finishChains(chainNodes);
+ }
+ _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
+ } else {
+ ret = this._getter.call(obj, keyName);
+ }
+ return ret;
+ };
+
+ /**
+ Set the value of a computed property. If the function that backs your
+ computed property does not accept arguments then the default action for
+ setting would be to define the property on the current object, and set
+ the value of the property to the value being set.
+
+ Generally speaking if you intend for your computed property to be set
+ your backing function should accept either two or three arguments.
+
+ ```javascript
+ var Person = Ember.Object.extend({
+ // these will be supplied by `create`
+ firstName: null,
+ lastName: null,
+
+ fullName: function(key, value, oldValue) {
+ // getter
+ if (arguments.length === 1) {
+ var firstName = this.get('firstName');
+ var lastName = this.get('lastName');
+
+ return firstName + ' ' + lastName;
+
+ // setter
+ } else {
+ var name = value.split(' ');
+
+ this.set('firstName', name[0]);
+ this.set('lastName', name[1]);
+
+ return value;
+ }
+ }.property('firstName', 'lastName')
+ });
+
+ var person = Person.create();
+
+ person.set('fullName', 'Peter Wagenet');
+ person.get('firstName'); // 'Peter'
+ person.get('lastName'); // 'Wagenet'
+ ```
+
+ @method set
+ @param {String} keyName The key being accessed.
+ @param {Object} newValue The new value being assigned.
+ @param {String} oldValue The old value being replaced.
+ @return {Object} The return value of the function backing the CP.
+ @public
+ */
+ ComputedPropertyPrototype.set = function computedPropertySetWithSuspend(obj, keyName, value) {
+ var oldSuspended = this._suspended;
+
+ this._suspended = obj;
+
+ try {
+ this._set(obj, keyName, value);
+ } finally {
+ this._suspended = oldSuspended;
+ }
+ };
+
+ ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) {
+ var cacheable = this._cacheable;
+ var setter = this._setter;
+ var meta = metaFor(obj, cacheable);
+ var cache = meta.cache;
+ var hadCachedValue = false;
+
+ var cachedValue, ret;
+
+ if (this._readOnly) {
+ throw new _emberMetalError["default"]("Cannot set read-only property \"" + keyName + "\" on object: " + _emberMetalUtils.inspect(obj));
+ }
+
+ if (cacheable && cache && cache[keyName] !== undefined) {
+ if (cache[keyName] !== UNDEFINED) {
+ cachedValue = cache[keyName];
+ }
+
+ hadCachedValue = true;
+ }
+
+ if (!setter) {
+ _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue);
+ _emberMetalProperty_set.set(obj, keyName, value);
+ return;
+ } else if (setter.__ember_arity === 2) {
+ // Is there any way of deprecate this in a sensitive way?
+ // Maybe now that getters and setters are the prefered options we can....
+ ret = setter.call(obj, keyName, value);
+ } else {
+ ret = setter.call(obj, keyName, value, cachedValue);
+ }
+
+ if (hadCachedValue && cachedValue === ret) {
+ return;
+ }
+
+ var watched = meta.watching[keyName];
+ if (watched) {
+ _emberMetalProperty_events.propertyWillChange(obj, keyName);
+ }
+
+ if (hadCachedValue) {
+ cache[keyName] = undefined;
+ }
+
+ if (cacheable) {
+ if (!hadCachedValue) {
+ _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
+ }
+ if (!cache) {
+ cache = meta.cache = {};
+ }
+ if (ret === undefined) {
+ cache[keyName] = UNDEFINED;
+ } else {
+ cache[keyName] = ret;
+ }
+ }
+
+ if (watched) {
+ _emberMetalProperty_events.propertyDidChange(obj, keyName);
+ }
+
+ return ret;
+ };
+
+ /* called before property is overridden */
+ ComputedPropertyPrototype.teardown = function (obj, keyName) {
+ var meta = metaFor(obj);
+
+ if (meta.cache) {
+ if (keyName in meta.cache) {
+ _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta);
+ }
+
+ if (this._cacheable) {
+ delete meta.cache[keyName];
+ }
+ }
+
+ return null; // no value to restore
+ };
+
+ /**
+ 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()`.
+
+ The function you pass will be used to both get and set property values.
+ The 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
+ var Person = Ember.Object.extend({
+ firstName: 'Betty',
+ lastName: 'Jones',
+
+ fullName: Ember.computed('firstName', 'lastName', function(key, value) {
+ return this.get('firstName') + ' ' + this.get('lastName');
+ })
+ });
+
+ var client = Person.create();
+
+ client.get('fullName'); // 'Betty Jones'
+
+ client.set('lastName', 'Fuller');
+ client.get('fullName'); // 'Betty Fuller'
+ ```
+
+ _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._
+
+ 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):
+
+ ```js
+ fullName: function () {
+ return this.get('firstName') + ' ' + this.get('lastName');
+ }.property('firstName', 'lastName')
+ ```
+
+ @class computed
+ @namespace Ember
+ @constructor
+ @static
+ @param {String} [dependentKeys*] Optional dependent keys that trigger this computed property.
+ @param {Function} func The computed property function.
+ @return {Ember.ComputedProperty} property descriptor instance
+ @public
+ */
+ function computed(func) {
+ var args;
+
+ if (arguments.length > 1) {
+ args = [].slice.call(arguments);
+ func = args.pop();
+ }
+
+ var cp = new ComputedProperty(func);
+
+ if (args) {
+ cp.property.apply(cp, args);
+ }
+
+ return cp;
+ }
+
+ /**
+ Returns the cached value for a property, if one exists.
+ This can be useful for peeking at the value of a computed
+ property that is generated lazily, without accidentally causing
+ it to be created.
+
+ @method cacheFor
+ @for Ember
+ @param {Object} obj the object whose property you want to check
+ @param {String} key the name of the property whose cached value you want
+ to return
+ @return {Object} the cached value
+ @public
+ */
+ function cacheFor(obj, key) {
+ var meta = obj['__ember_meta__'];
+ var cache = meta && meta.cache;
+ var ret = cache && cache[key];
+
+ if (ret === UNDEFINED) {
+ return undefined;
+ }
+ return ret;
+ }
+
+ cacheFor.set = function (cache, key, value) {
+ if (value === undefined) {
+ cache[key] = UNDEFINED;
+ } else {
+ cache[key] = value;
+ }
+ };
+
+ cacheFor.get = function (cache, key) {
+ var ret = cache[key];
+ if (ret === UNDEFINED) {
+ return undefined;
+ }
+ return ret;
+ };
+
+ cacheFor.remove = function (cache, key) {
+ cache[key] = undefined;
+ };
+
+ exports.ComputedProperty = ComputedProperty;
+ exports.computed = computed;
+ exports.cacheFor = cacheFor;
+});
enifed("ember-metal/computed_macros", ["exports", "ember-metal/core", "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, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalComputed, _emberMetalIs_empty, _emberMetalIs_none, _emberMetalAlias) {
"use strict";
exports.empty = empty;
exports.notEmpty = notEmpty;
@@ -2642,642 +3274,10 @@
return value;
}
});
}
});
-enifed("ember-metal/computed", ["exports", "ember-metal/core", "ember-metal/property_set", "ember-metal/utils", "ember-metal/expand_properties", "ember-metal/error", "ember-metal/properties", "ember-metal/property_events", "ember-metal/dependent_keys"], function (exports, _emberMetalCore, _emberMetalProperty_set, _emberMetalUtils, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) {
- "use strict";
-
- /**
- @module ember
- @submodule ember-metal
- */
-
- var metaFor = _emberMetalUtils.meta;
-
- function UNDEFINED() {}
-
- // ..........................................................
- // COMPUTED PROPERTY
- //
-
- /**
- A computed property transforms an object's function into a property.
-
- By default the function backing the computed property will only be called
- once and the result will be cached. You can specify various properties
- that your computed property depends on. This will force the cached
- result to be recomputed if the dependencies are modified.
-
- In the following example we declare a computed property (by calling
- `.property()` on the fullName function) and setup the property
- dependencies (depending on firstName and lastName). The fullName function
- will be called once (regardless of how many times it is accessed) as long
- as its dependencies have not changed. Once firstName or lastName are updated
- any future calls (or anything bound) to fullName will incorporate the new
- values.
-
- ```javascript
- var Person = Ember.Object.extend({
- // these will be supplied by `create`
- firstName: null,
- lastName: null,
-
- fullName: function() {
- var firstName = this.get('firstName');
- var lastName = this.get('lastName');
-
- return firstName + ' ' + lastName;
- }.property('firstName', 'lastName')
- });
-
- var tom = Person.create({
- firstName: 'Tom',
- lastName: 'Dale'
- });
-
- tom.get('fullName') // 'Tom Dale'
- ```
-
- You can also define what Ember should do when setting a computed property.
- If you try to set a computed property, it will be invoked with the key and
- value you want to set it to. You can also accept the previous value as the
- third parameter.
-
- ```javascript
- var Person = Ember.Object.extend({
- // these will be supplied by `create`
- firstName: null,
- lastName: null,
-
- fullName: function(key, value, oldValue) {
- // getter
- if (arguments.length === 1) {
- var firstName = this.get('firstName');
- var lastName = this.get('lastName');
-
- return firstName + ' ' + lastName;
-
- // setter
- } else {
- var name = value.split(' ');
-
- this.set('firstName', name[0]);
- this.set('lastName', name[1]);
-
- return value;
- }
- }.property('firstName', 'lastName')
- });
-
- var person = Person.create();
-
- person.set('fullName', 'Peter Wagenet');
- person.get('firstName'); // 'Peter'
- person.get('lastName'); // 'Wagenet'
- ```
-
- @class ComputedProperty
- @namespace Ember
- @constructor
- @public
- */
- function ComputedProperty(config, opts) {
- this.isDescriptor = true;
- if (typeof config === "function") {
- config.__ember_arity = config.length;
- this._getter = config;
- if (config.__ember_arity > 1) {
- _emberMetalCore["default"].deprecate("Using the same function as getter and setter is deprecated.", false, {
- url: "http://emberjs.com/deprecations/v1.x/#toc_deprecate-using-the-same-function-as-getter-and-setter-in-computed-properties"
- });
- this._setter = config;
- }
- } else {
- this._getter = config.get;
- this._setter = config.set;
- if (this._setter && this._setter.__ember_arity === undefined) {
- this._setter.__ember_arity = this._setter.length;
- }
- }
-
- this._dependentKeys = undefined;
- this._suspended = undefined;
- this._meta = undefined;
-
- _emberMetalCore["default"].deprecate("Passing opts.cacheable to the CP constructor is deprecated. Invoke `volatile()` on the CP instead.", !opts || !opts.hasOwnProperty('cacheable'));
- this._cacheable = opts && opts.cacheable !== undefined ? opts.cacheable : true; // TODO: Set always to `true` once this deprecation is gone.
- this._dependentKeys = opts && opts.dependentKeys;
- _emberMetalCore["default"].deprecate("Passing opts.readOnly to the CP constructor is deprecated. All CPs are writable by default. You can invoke `readOnly()` on the CP to change this.", !opts || !opts.hasOwnProperty('readOnly'));
- this._readOnly = opts && (opts.readOnly !== undefined || !!opts.readOnly) || false; // TODO: Set always to `false` once this deprecation is gone.
- }
-
- ComputedProperty.prototype = new _emberMetalProperties.Descriptor();
-
- var ComputedPropertyPrototype = ComputedProperty.prototype;
-
- /**
- Properties are cacheable by default. Computed property will automatically
- cache the return value of your function until one of the dependent keys changes.
-
- Call `volatile()` to set it into non-cached mode. When in this mode
- the computed property will not automatically cache the return value.
-
- However, if a property is properly observable, there is no reason to disable
- caching.
-
- @method cacheable
- @param {Boolean} aFlag optional set to `false` to disable caching
- @return {Ember.ComputedProperty} this
- @chainable
- @deprecated All computed properties are cacheble by default. Use `volatile()` instead to opt-out to caching.
- @public
- */
- ComputedPropertyPrototype.cacheable = function (aFlag) {
- _emberMetalCore["default"].deprecate('ComputedProperty.cacheable() is deprecated. All computed properties are cacheable by default.');
- this._cacheable = aFlag !== false;
- return this;
- };
-
- /**
- Call on a computed property to set it into non-cached mode. When in this
- mode the computed property will not automatically cache the return value.
-
- ```javascript
- var outsideService = Ember.Object.extend({
- value: function() {
- return OutsideService.getValue();
- }.property().volatile()
- }).create();
- ```
-
- @method volatile
- @return {Ember.ComputedProperty} this
- @chainable
- @public
- */
- ComputedPropertyPrototype["volatile"] = function () {
- this._cacheable = false;
- return this;
- };
-
- /**
- Call on a computed property to set it into read-only mode. When in this
- mode the computed property will throw an error when set.
-
- ```javascript
- var Person = Ember.Object.extend({
- guid: function() {
- return 'guid-guid-guid';
- }.property().readOnly()
- });
-
- var person = Person.create();
-
- person.set('guid', 'new-guid'); // will throw an exception
- ```
-
- @method readOnly
- @return {Ember.ComputedProperty} this
- @chainable
- @public
- */
- ComputedPropertyPrototype.readOnly = function (readOnly) {
- _emberMetalCore["default"].deprecate('Passing arguments to ComputedProperty.readOnly() is deprecated.', arguments.length === 0);
- this._readOnly = readOnly === undefined || !!readOnly; // Force to true once this deprecation is gone
- _emberMetalCore["default"].assert("Computed properties that define a setter using the new syntax cannot be read-only", !(this._readOnly && this._setter && this._setter !== this._getter));
- return this;
- };
-
- /**
- Sets the dependent keys on this computed property. Pass any number of
- arguments containing key paths that this computed property depends on.
-
- ```javascript
- var President = Ember.Object.extend({
- fullName: computed(function() {
- return this.get('firstName') + ' ' + this.get('lastName');
-
- // Tell Ember that this computed property depends on firstName
- // and lastName
- }).property('firstName', 'lastName')
- });
-
- var president = President.create({
- firstName: 'Barack',
- lastName: 'Obama'
- });
-
- president.get('fullName'); // 'Barack Obama'
- ```
-
- @method property
- @param {String} path* zero or more property paths
- @return {Ember.ComputedProperty} this
- @chainable
- @public
- */
- ComputedPropertyPrototype.property = function () {
- var args;
-
- var addArg = function (property) {
- _emberMetalCore["default"].deprecate("Depending on arrays using a dependent key ending with `@each` is deprecated. " + ("Please refactor from `Ember.computed('" + property + "', function() {});` to `Ember.computed('" + property.slice(0, -6) + ".[]', function() {})`."), property.slice(-5) !== '@each', { id: 'ember-metal.@each-dependent-key-leaf', until: '2.0.0' });
-
- args.push(property);
- };
-
- args = [];
- for (var i = 0, l = arguments.length; i < l; i++) {
- _emberMetalExpand_properties["default"](arguments[i], addArg);
- }
-
- this._dependentKeys = args;
- return this;
- };
-
- /**
- In some cases, you may want to annotate computed properties with additional
- metadata about how they function or what values they operate on. For example,
- computed property functions may close over variables that are then no longer
- available for introspection.
-
- You can pass a hash of these values to a computed property like this:
-
- ```
- person: function() {
- var personId = this.get('personId');
- return App.Person.create({ id: personId });
- }.property().meta({ type: App.Person })
- ```
-
- The hash that you pass to the `meta()` function will be saved on the
- computed property descriptor under the `_meta` key. Ember runtime
- exposes a public API for retrieving these values from classes,
- via the `metaForProperty()` function.
-
- @method meta
- @param {Object} meta
- @chainable
- @public
- */
-
- ComputedPropertyPrototype.meta = function (meta) {
- if (arguments.length === 0) {
- return this._meta || {};
- } else {
- this._meta = meta;
- return this;
- }
- };
-
- /* impl descriptor API */
- ComputedPropertyPrototype.didChange = function (obj, keyName) {
- // _suspended is set via a CP.set to ensure we don't clear
- // the cached value set by the setter
- if (this._cacheable && this._suspended !== obj) {
- var meta = metaFor(obj);
- if (meta.cache && meta.cache[keyName] !== undefined) {
- meta.cache[keyName] = undefined;
- _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta);
- }
- }
- };
-
- function finishChains(chainNodes) {
- for (var i = 0, l = chainNodes.length; i < l; i++) {
- chainNodes[i].didChange(null);
- }
- }
-
- /**
- Access the value of the function backing the computed property.
- If this property has already been cached, return the cached result.
- Otherwise, call the function passing the property name as an argument.
-
- ```javascript
- var Person = Ember.Object.extend({
- fullName: function(keyName) {
- // the keyName parameter is 'fullName' in this case.
- return this.get('firstName') + ' ' + this.get('lastName');
- }.property('firstName', 'lastName')
- });
-
-
- var tom = Person.create({
- firstName: 'Tom',
- lastName: 'Dale'
- });
-
- tom.get('fullName') // 'Tom Dale'
- ```
-
- @method get
- @param {String} keyName The key being accessed.
- @return {Object} The return value of the function backing the CP.
- @public
- */
- ComputedPropertyPrototype.get = function (obj, keyName) {
- var ret, cache, meta, chainNodes;
- if (this._cacheable) {
- meta = metaFor(obj);
- cache = meta.cache;
-
- var result = cache && cache[keyName];
-
- if (result === UNDEFINED) {
- return undefined;
- } else if (result !== undefined) {
- return result;
- }
-
- ret = this._getter.call(obj, keyName);
- cache = meta.cache;
- if (!cache) {
- cache = meta.cache = {};
- }
- if (ret === undefined) {
- cache[keyName] = UNDEFINED;
- } else {
- cache[keyName] = ret;
- }
-
- chainNodes = meta.chainWatchers && meta.chainWatchers[keyName];
- if (chainNodes) {
- finishChains(chainNodes);
- }
- _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
- } else {
- ret = this._getter.call(obj, keyName);
- }
- return ret;
- };
-
- /**
- Set the value of a computed property. If the function that backs your
- computed property does not accept arguments then the default action for
- setting would be to define the property on the current object, and set
- the value of the property to the value being set.
-
- Generally speaking if you intend for your computed property to be set
- your backing function should accept either two or three arguments.
-
- ```javascript
- var Person = Ember.Object.extend({
- // these will be supplied by `create`
- firstName: null,
- lastName: null,
-
- fullName: function(key, value, oldValue) {
- // getter
- if (arguments.length === 1) {
- var firstName = this.get('firstName');
- var lastName = this.get('lastName');
-
- return firstName + ' ' + lastName;
-
- // setter
- } else {
- var name = value.split(' ');
-
- this.set('firstName', name[0]);
- this.set('lastName', name[1]);
-
- return value;
- }
- }.property('firstName', 'lastName')
- });
-
- var person = Person.create();
-
- person.set('fullName', 'Peter Wagenet');
- person.get('firstName'); // 'Peter'
- person.get('lastName'); // 'Wagenet'
- ```
-
- @method set
- @param {String} keyName The key being accessed.
- @param {Object} newValue The new value being assigned.
- @param {String} oldValue The old value being replaced.
- @return {Object} The return value of the function backing the CP.
- @public
- */
- ComputedPropertyPrototype.set = function computedPropertySetWithSuspend(obj, keyName, value) {
- var oldSuspended = this._suspended;
-
- this._suspended = obj;
-
- try {
- this._set(obj, keyName, value);
- } finally {
- this._suspended = oldSuspended;
- }
- };
-
- ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, value) {
- var cacheable = this._cacheable;
- var setter = this._setter;
- var meta = metaFor(obj, cacheable);
- var cache = meta.cache;
- var hadCachedValue = false;
-
- var cachedValue, ret;
-
- if (this._readOnly) {
- throw new _emberMetalError["default"]("Cannot set read-only property \"" + keyName + "\" on object: " + _emberMetalUtils.inspect(obj));
- }
-
- if (cacheable && cache && cache[keyName] !== undefined) {
- if (cache[keyName] !== UNDEFINED) {
- cachedValue = cache[keyName];
- }
-
- hadCachedValue = true;
- }
-
- if (!setter) {
- _emberMetalProperties.defineProperty(obj, keyName, null, cachedValue);
- _emberMetalProperty_set.set(obj, keyName, value);
- return;
- } else if (setter.__ember_arity === 2) {
- // Is there any way of deprecate this in a sensitive way?
- // Maybe now that getters and setters are the prefered options we can....
- ret = setter.call(obj, keyName, value);
- } else {
- ret = setter.call(obj, keyName, value, cachedValue);
- }
-
- if (hadCachedValue && cachedValue === ret) {
- return;
- }
-
- var watched = meta.watching[keyName];
- if (watched) {
- _emberMetalProperty_events.propertyWillChange(obj, keyName);
- }
-
- if (hadCachedValue) {
- cache[keyName] = undefined;
- }
-
- if (cacheable) {
- if (!hadCachedValue) {
- _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
- }
- if (!cache) {
- cache = meta.cache = {};
- }
- if (ret === undefined) {
- cache[keyName] = UNDEFINED;
- } else {
- cache[keyName] = ret;
- }
- }
-
- if (watched) {
- _emberMetalProperty_events.propertyDidChange(obj, keyName);
- }
-
- return ret;
- };
-
- /* called before property is overridden */
- ComputedPropertyPrototype.teardown = function (obj, keyName) {
- var meta = metaFor(obj);
-
- if (meta.cache) {
- if (keyName in meta.cache) {
- _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta);
- }
-
- if (this._cacheable) {
- delete meta.cache[keyName];
- }
- }
-
- return null; // no value to restore
- };
-
- /**
- 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()`.
-
- The function you pass will be used to both get and set property values.
- The 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
- var Person = Ember.Object.extend({
- firstName: 'Betty',
- lastName: 'Jones',
-
- fullName: Ember.computed('firstName', 'lastName', function(key, value) {
- return this.get('firstName') + ' ' + this.get('lastName');
- })
- });
-
- var client = Person.create();
-
- client.get('fullName'); // 'Betty Jones'
-
- client.set('lastName', 'Fuller');
- client.get('fullName'); // 'Betty Fuller'
- ```
-
- _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._
-
- 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):
-
- ```js
- fullName: function () {
- return this.get('firstName') + ' ' + this.get('lastName');
- }.property('firstName', 'lastName')
- ```
-
- @class computed
- @namespace Ember
- @constructor
- @static
- @param {String} [dependentKeys*] Optional dependent keys that trigger this computed property.
- @param {Function} func The computed property function.
- @return {Ember.ComputedProperty} property descriptor instance
- @public
- */
- function computed(func) {
- var args;
-
- if (arguments.length > 1) {
- args = [].slice.call(arguments);
- func = args.pop();
- }
-
- var cp = new ComputedProperty(func);
-
- if (args) {
- cp.property.apply(cp, args);
- }
-
- return cp;
- }
-
- /**
- Returns the cached value for a property, if one exists.
- This can be useful for peeking at the value of a computed
- property that is generated lazily, without accidentally causing
- it to be created.
-
- @method cacheFor
- @for Ember
- @param {Object} obj the object whose property you want to check
- @param {String} key the name of the property whose cached value you want
- to return
- @return {Object} the cached value
- @public
- */
- function cacheFor(obj, key) {
- var meta = obj['__ember_meta__'];
- var cache = meta && meta.cache;
- var ret = cache && cache[key];
-
- if (ret === UNDEFINED) {
- return undefined;
- }
- return ret;
- }
-
- cacheFor.set = function (cache, key, value) {
- if (value === undefined) {
- cache[key] = UNDEFINED;
- } else {
- cache[key] = value;
- }
- };
-
- cacheFor.get = function (cache, key) {
- var ret = cache[key];
- if (ret === UNDEFINED) {
- return undefined;
- }
- return ret;
- };
-
- cacheFor.remove = function (cache, key) {
- cache[key] = undefined;
- };
-
- exports.ComputedProperty = ComputedProperty;
- exports.computed = computed;
- exports.cacheFor = cacheFor;
-});
enifed('ember-metal/core', ['exports'], function (exports) {
/*globals Ember:true,ENV,EmberENV */
/**
@module ember
@@ -3297,11 +3297,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 1.13.12
+ @version 1.13.13
@public
*/
'use strict';
@@ -3331,15 +3331,15 @@
/**
The semantic version.
@property VERSION
@type String
- @default '1.13.12'
+ @default '1.13.13'
@static
@public
*/
- Ember.VERSION = '1.13.12';
+ Ember.VERSION = '1.13.13';
/**
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
@@ -6978,79 +6978,10 @@
exports.Mixin = Mixin;
exports.required = required;
exports.REQUIRED = REQUIRED;
});
// warn, assert, wrap, et;
-enifed("ember-metal/observer_set", ["exports", "ember-metal/utils", "ember-metal/events"], function (exports, _emberMetalUtils, _emberMetalEvents) {
- "use strict";
-
- /*
- this.observerSet = {
- [senderGuid]: { // variable name: `keySet`
- [keyName]: listIndex
- }
- },
- this.observers = [
- {
- sender: obj,
- keyName: keyName,
- eventName: eventName,
- listeners: [
- [target, method, flags]
- ]
- },
- ...
- ]
- */
- exports["default"] = ObserverSet;
-
- function ObserverSet() {
- this.clear();
- }
-
- ObserverSet.prototype.add = function (sender, keyName, eventName) {
- var observerSet = this.observerSet;
- var observers = this.observers;
- var senderGuid = _emberMetalUtils.guidFor(sender);
- var keySet = observerSet[senderGuid];
- var index;
-
- if (!keySet) {
- observerSet[senderGuid] = keySet = {};
- }
- index = keySet[keyName];
- if (index === undefined) {
- index = observers.push({
- sender: sender,
- keyName: keyName,
- eventName: eventName,
- listeners: []
- }) - 1;
- keySet[keyName] = index;
- }
- return observers[index].listeners;
- };
-
- ObserverSet.prototype.flush = function () {
- var observers = this.observers;
- var i, len, observer, sender;
- this.clear();
- for (i = 0, len = observers.length; i < len; ++i) {
- observer = observers[i];
- sender = observer.sender;
- if (sender.isDestroying || sender.isDestroyed) {
- continue;
- }
- _emberMetalEvents.sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners);
- }
- };
-
- ObserverSet.prototype.clear = function () {
- this.observerSet = {};
- this.observers = [];
- };
-});
enifed("ember-metal/observer", ["exports", "ember-metal/watching", "ember-metal/array", "ember-metal/events"], function (exports, _emberMetalWatching, _emberMetalArray, _emberMetalEvents) {
"use strict";
exports.addObserver = addObserver;
exports.observersFor = observersFor;
@@ -7177,10 +7108,79 @@
_emberMetalEvents.removeListener(obj, beforeEvent(path), target, method);
return this;
}
});
+enifed("ember-metal/observer_set", ["exports", "ember-metal/utils", "ember-metal/events"], function (exports, _emberMetalUtils, _emberMetalEvents) {
+ "use strict";
+
+ /*
+ this.observerSet = {
+ [senderGuid]: { // variable name: `keySet`
+ [keyName]: listIndex
+ }
+ },
+ this.observers = [
+ {
+ sender: obj,
+ keyName: keyName,
+ eventName: eventName,
+ listeners: [
+ [target, method, flags]
+ ]
+ },
+ ...
+ ]
+ */
+ exports["default"] = ObserverSet;
+
+ function ObserverSet() {
+ this.clear();
+ }
+
+ ObserverSet.prototype.add = function (sender, keyName, eventName) {
+ var observerSet = this.observerSet;
+ var observers = this.observers;
+ var senderGuid = _emberMetalUtils.guidFor(sender);
+ var keySet = observerSet[senderGuid];
+ var index;
+
+ if (!keySet) {
+ observerSet[senderGuid] = keySet = {};
+ }
+ index = keySet[keyName];
+ if (index === undefined) {
+ index = observers.push({
+ sender: sender,
+ keyName: keyName,
+ eventName: eventName,
+ listeners: []
+ }) - 1;
+ keySet[keyName] = index;
+ }
+ return observers[index].listeners;
+ };
+
+ ObserverSet.prototype.flush = function () {
+ var observers = this.observers;
+ var i, len, observer, sender;
+ this.clear();
+ for (i = 0, len = observers.length; i < len; ++i) {
+ observer = observers[i];
+ sender = observer.sender;
+ if (sender.isDestroying || sender.isDestroyed) {
+ continue;
+ }
+ _emberMetalEvents.sendEvent(sender, observer.eventName, [sender, observer.keyName], observer.listeners);
+ }
+ };
+
+ ObserverSet.prototype.clear = function () {
+ this.observerSet = {};
+ this.observers = [];
+ };
+});
enifed('ember-metal/path_cache', ['exports', 'ember-metal/cache'], function (exports, _emberMetalCache) {
'use strict';
exports.isGlobal = isGlobal;
exports.isGlobalPath = isGlobalPath;
@@ -12587,10 +12587,45 @@
}
return moduleInfo;
}
});
+enifed("ember-template-compiler/system/compile", ["exports", "ember-template-compiler/system/compile_options", "ember-template-compiler/system/template"], function (exports, _emberTemplateCompilerSystemCompile_options, _emberTemplateCompilerSystemTemplate) {
+ /**
+ @module ember
+ @submodule ember-template-compiler
+ */
+
+ "use strict";
+
+ var compile;
+
+ /**
+ Uses HTMLBars `compile` function to process a string into a compiled template.
+
+ This is not present in production builds.
+
+ @private
+ @method compile
+ @param {String} templateString This is the string to be compiled by HTMLBars.
+ @param {Object} options This is an options hash to augment the compiler options.
+ */
+
+ exports["default"] = function (templateString, options) {
+ if (!compile && Ember.__loader.registry['htmlbars-compiler/compiler']) {
+ compile = requireModule('htmlbars-compiler/compiler').compile;
+ }
+
+ if (!compile) {
+ throw new Error('Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`.');
+ }
+
+ var templateSpec = compile(templateString, _emberTemplateCompilerSystemCompile_options["default"](options));
+
+ return _emberTemplateCompilerSystemTemplate["default"](templateSpec);
+ };
+});
enifed("ember-template-compiler/system/compile_options", ["exports", "ember-metal/core", "ember-metal/merge", "ember-template-compiler/plugins"], function (exports, _emberMetalCore, _emberMetalMerge, _emberTemplateCompilerPlugins) {
/**
@module ember
@submodule ember-template-compiler
*/
@@ -12626,54 +12661,19 @@
}
options.plugins = plugins;
options.buildMeta = function buildMeta(program) {
return {
- revision: 'Ember@1.13.12',
+ revision: 'Ember@1.13.13',
loc: program.loc,
moduleName: options.moduleName
};
};
return options;
};
});
-enifed("ember-template-compiler/system/compile", ["exports", "ember-template-compiler/system/compile_options", "ember-template-compiler/system/template"], function (exports, _emberTemplateCompilerSystemCompile_options, _emberTemplateCompilerSystemTemplate) {
- /**
- @module ember
- @submodule ember-template-compiler
- */
-
- "use strict";
-
- var compile;
-
- /**
- Uses HTMLBars `compile` function to process a string into a compiled template.
-
- This is not present in production builds.
-
- @private
- @method compile
- @param {String} templateString This is the string to be compiled by HTMLBars.
- @param {Object} options This is an options hash to augment the compiler options.
- */
-
- exports["default"] = function (templateString, options) {
- if (!compile && Ember.__loader.registry['htmlbars-compiler/compiler']) {
- compile = requireModule('htmlbars-compiler/compiler').compile;
- }
-
- if (!compile) {
- throw new Error('Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`.');
- }
-
- var templateSpec = compile(templateString, _emberTemplateCompilerSystemCompile_options["default"](options));
-
- return _emberTemplateCompilerSystemTemplate["default"](templateSpec);
- };
-});
enifed('ember-template-compiler/system/precompile', ['exports', 'ember-template-compiler/system/compile_options'], function (exports, _emberTemplateCompilerSystemCompile_options) {
/**
@module ember
@submodule ember-template-compiler
*/
@@ -14482,11 +14482,11 @@
var yieldArgs = yieldTemplate(template, env, scope, morph, renderState, visitor);
return {
meta: template.meta,
arity: template.arity,
- yield: yieldArgs,
+ "yield": yieldArgs,
yieldItem: yieldItem(template, env, scope, morph, renderState, visitor),
yieldIn: yieldInShadowTemplate(template, env, scope, morph, renderState, visitor),
raw: template,
render: function (self, blockArguments) {
@@ -14718,11 +14718,11 @@
}
function thisFor(options) {
return {
arity: options.template.arity,
- yield: options.template.yield,
+ "yield": options.template["yield"],
yieldItem: options.template.yieldItem,
yieldIn: options.template.yieldIn
};
}
@@ -15205,10 +15205,10 @@
var value = env.hooks.partial(morph, env, scope, params[0]);
morph.setContent(value);
return true;
},
- yield: function (morph, env, scope, params, hash, template, inverse, visitor) {
+ "yield": function (morph, env, scope, params, hash, template, inverse, visitor) {
// the current scope is provided purely for the creation of shadow
// scopes; it should not be provided to user code.
var to = env.hooks.getValue(hash.to) || 'default';
if (scope.blocks[to]) {
\ No newline at end of file